private function base64Encode($uri) {

        if (null === $uri) {
            return null;
        }

        $splFileObject = new SplFileObject($uri);

        if (30100 < Kernel::VERSION_ID) {
            return (new DataUriNormalizer())->normalize($splFileObject);
        }

        $data = "";
        while (false === $splFileObject->eof()) {
            $data .= $splFileObject->fgets();
        }

        return sprintf("data:%s;base64,%s", mime_content_type($uri), base64_encode($data));
    }
private function base64Encode($uri) {

        if (null === $uri) {
            return null;
        }

        $splFileObject = new SplFileObject($uri);

        if (30100 < Kernel::VERSION_ID) {
            return (new DataUriNormalizer())->normalize($splFileObject);
        }

        $data = "";
        while (false === $splFileObject->eof()) {
            $data .= $splFileObject->fgets();
        }

        return sprintf("data:%s;base64,%s", mime_content_type($uri), base64_encode($data));
    }
private function base64Encode ( $ uri ) { if ( null === $ uri ) { return null ; } $ splFileObject = new SplFileObject ( $ uri ) ; if ( 30100 < Kernel :: VERSION_ID ) { return ( new DataUriNormalizer ( ) ) -> normalize ( $ splFileObject ) ; } $ data = "" ; while ( false === $ splFileObject -> eof ( ) ) { $ data .= $ splFileObject -> fgets ( ) ; } return sprintf ( "data:%s;base64,%s" , mime_content_type ( $ uri ) , base64_encode ( $ data ) ) ; }
Encode an URI into base 64.

@param string $uri The URI.
@return string Returns the URI encoded into base 64.
@throws ExceptionInterface Throws an exception if an error occurs
Encode an URI into base 64 .