private function formatDataPath(string $path): string
    {
        if ('data' !== $this->scheme) {
            return $path;
        }

        if ('' == $path) {
            return 'text/plain;charset=us-ascii,';
        }

        if (false === mb_detect_encoding($path, 'US-ASCII', true) || false === strpos($path, ',')) {
            throw new SyntaxError(sprintf('The path `%s` is invalid according to RFC2937', $path));
        }

        $parts = explode(',', $path, 2) + [1 => null];
        $mediatype = explode(';', (string) $parts[0], 2) + [1 => null];
        $data = (string) $parts[1];
        $mimetype = $mediatype[0];
        if (null === $mimetype || '' === $mimetype) {
            $mimetype = 'text/plain';
        }

        $parameters = $mediatype[1];
        if (null === $parameters || '' === $parameters) {
            $parameters = 'charset=us-ascii';
        }

        $this->assertValidPath($mimetype, $parameters, $data);

        return $mimetype.';'.$parameters.','.$data;
    }
private function formatDataPath(string $path): string
    {
        if ('data' !== $this->scheme) {
            return $path;
        }

        if ('' == $path) {
            return 'text/plain;charset=us-ascii,';
        }

        if (false === mb_detect_encoding($path, 'US-ASCII', true) || false === strpos($path, ',')) {
            throw new SyntaxError(sprintf('The path `%s` is invalid according to RFC2937', $path));
        }

        $parts = explode(',', $path, 2) + [1 => null];
        $mediatype = explode(';', (string) $parts[0], 2) + [1 => null];
        $data = (string) $parts[1];
        $mimetype = $mediatype[0];
        if (null === $mimetype || '' === $mimetype) {
            $mimetype = 'text/plain';
        }

        $parameters = $mediatype[1];
        if (null === $parameters || '' === $parameters) {
            $parameters = 'charset=us-ascii';
        }

        $this->assertValidPath($mimetype, $parameters, $data);

        return $mimetype.';'.$parameters.','.$data;
    }
private function formatDataPath ( string $ path ) : string { if ( 'data' !== $ this -> scheme ) { return $ path ; } if ( '' == $ path ) { return 'text/plain;charset=us-ascii,' ; } if ( false === mb_detect_encoding ( $ path , 'US-ASCII' , true ) || false === strpos ( $ path , ',' ) ) { throw new SyntaxError ( sprintf ( 'The path `%s` is invalid according to RFC2937' , $ path ) ) ; } $ parts = explode ( ',' , $ path , 2 ) + [ 1 => null ] ; $ mediatype = explode ( ';' , ( string ) $ parts [ 0 ] , 2 ) + [ 1 => null ] ; $ data = ( string ) $ parts [ 1 ] ; $ mimetype = $ mediatype [ 0 ] ; if ( null === $ mimetype || '' === $ mimetype ) { $ mimetype = 'text/plain' ; } $ parameters = $ mediatype [ 1 ] ; if ( null === $ parameters || '' === $ parameters ) { $ parameters = 'charset=us-ascii' ; } $ this -> assertValidPath ( $ mimetype , $ parameters , $ data ) ; return $ mimetype . ';' . $ parameters . ',' . $ data ; }
Filter the Path component.

@see https://tools.ietf.org/html/rfc2397

@throws SyntaxError If the path is not compliant with RFC2397
Filter the Path component .