public static function tryParse($dataUriString, &$out)
    {
        $hasOutput = false;

        if (self::isParsable($dataUriString)) {
            $matches = null;
            if (preg_match_all(self::$REGEX_URI, $dataUriString, $matches, PREG_SET_ORDER) !== false) {
                $mediatype = isset($matches[0][1]) ? $matches[0][1] : self::DEFAULT_TYPE;

                $matchedEncoding = isset($matches[0][2]) ? $matches[0][2] : '';
                $encoding = (strtolower($matchedEncoding) === self::BASE64_KEYWORD) ? self::ENCODING_BASE64 : self::ENCODING_URL_ENCODED_OCTETS;

                $data = isset($matches[0][3]) ? $matches[0][3] : '';

                $dataUri = new self();
                $dataUri->setMediaType($mediatype);
                $dataUri->setEncodedData($encoding, $data);

                $out = $dataUri;
                $hasOutput = true;
            }
        }

        return $hasOutput;
    }
public static function tryParse($dataUriString, &$out)
    {
        $hasOutput = false;

        if (self::isParsable($dataUriString)) {
            $matches = null;
            if (preg_match_all(self::$REGEX_URI, $dataUriString, $matches, PREG_SET_ORDER) !== false) {
                $mediatype = isset($matches[0][1]) ? $matches[0][1] : self::DEFAULT_TYPE;

                $matchedEncoding = isset($matches[0][2]) ? $matches[0][2] : '';
                $encoding = (strtolower($matchedEncoding) === self::BASE64_KEYWORD) ? self::ENCODING_BASE64 : self::ENCODING_URL_ENCODED_OCTETS;

                $data = isset($matches[0][3]) ? $matches[0][3] : '';

                $dataUri = new self();
                $dataUri->setMediaType($mediatype);
                $dataUri->setEncodedData($encoding, $data);

                $out = $dataUri;
                $hasOutput = true;
            }
        }

        return $hasOutput;
    }
public static function tryParse ( $ dataUriString , & $ out ) { $ hasOutput = false ; if ( self :: isParsable ( $ dataUriString ) ) { $ matches = null ; if ( preg_match_all ( self :: $ REGEX_URI , $ dataUriString , $ matches , PREG_SET_ORDER ) !== false ) { $ mediatype = isset ( $ matches [ 0 ] [ 1 ] ) ? $ matches [ 0 ] [ 1 ] : self :: DEFAULT_TYPE ; $ matchedEncoding = isset ( $ matches [ 0 ] [ 2 ] ) ? $ matches [ 0 ] [ 2 ] : '' ; $ encoding = ( strtolower ( $ matchedEncoding ) === self :: BASE64_KEYWORD ) ? self :: ENCODING_BASE64 : self :: ENCODING_URL_ENCODED_OCTETS ; $ data = isset ( $ matches [ 0 ] [ 3 ] ) ? $ matches [ 0 ] [ 3 ] : '' ; $ dataUri = new self ( ) ; $ dataUri -> setMediaType ( $ mediatype ) ; $ dataUri -> setEncodedData ( $ encoding , $ data ) ; $ out = $ dataUri ; $ hasOutput = true ; } } return $ hasOutput ; }
Parses a string data URI into an instance of a DataUri object.

@param string  $dataUriString Data URI to be parsed
@param DataUri $out           Output DataUri of the method

@return bool <code>true</code> if successful, else <code>false</code>
Parses a string data URI into an instance of a DataUri object .