Cloudinary::check_cloudinary_field PHP Method

check_cloudinary_field() public static method

Warning: $options are being destructively updated!
public static check_cloudinary_field ( $source, &$options = [] )
    public static function check_cloudinary_field($source, &$options = array())
    {
        $IDENTIFIER_RE = "~" . "^(?:([^/]+)/)??(?:([^/]+)/)??(?:(?:v(\\d+)/)(?:([^#]+)/)?)?" . "([^#/]+?)(?:\\.([^.#/]+))?(?:#([^/]+))?\$" . "~";
        $matches = array();
        if (!(is_object($source) && method_exists($source, 'identifier'))) {
            return $source;
        }
        $identifier = $source->identifier();
        if (!$identifier || strstr(':', $identifier) !== false || !preg_match($IDENTIFIER_RE, $identifier, $matches)) {
            return $source;
        }
        $optionNames = array('resource_type', 'type', 'version', 'folder', 'public_id', 'format');
        foreach ($optionNames as $index => $optionName) {
            if (@$matches[$index + 1]) {
                $options[$optionName] = $matches[$index + 1];
            }
        }
        return Cloudinary::option_consume($options, 'public_id');
    }