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;
    }