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