Gets mime type of binary

@param  string     $binary
@return string
@throws \Exception
500183
public function guess($binary)
    {
        $tmpFile = tempnam(sys_get_temp_dir(), 'ht-img-module');

        try {
            file_put_contents($tmpFile, $binary);

            $mimeType = $this->mimeTypeGuesser->guess($tmpFile);

            unlink($tmpFile);

            return $mimeType;
        } catch (\Exception $e) {
            unlink($tmpFile);

            throw $e;
        }
    }
647061
public function getMime($filename): string {
        $info = $this->_getApi()->getObject([
            'Bucket' => $this->_config['bucket'],
            'Key' => $this->_getUri($filename),
        ]);

        if (f\prop('ContentType', $info)) {
            return $info['ContentType'];
        }
        throw new Exception("Could not retrieve mime type of {$filename}.");
    }
398259
private function _toIp($binary)
    {
        $ip  = array();
        $tmp = explode(".", chunk_split($binary, 8, "."));
        for ($i = 0; $i < 4 ; $i++) {
            $ip[$i] = bindec($tmp[$i]);
        }

        return $ip;
    }
1118458
public static function getMimeTypeFromFilename($fileName)
    {
        $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
        if (array_key_exists($ext, self::$customMimeTypes)) {
            return self::$customMimeTypes[$ext];
        } else if (array_key_exists($ext, self::$mimeTypes)) {
            return self::$mimeTypes[$ext];
        }
        return 'application/octet-stream';
    }
698108
private function getMimeType($file)
    {
        $type = FileInfo::DIRECTORY_MIME_TYPE;
        if (is_file($file)) {
            if (class_exists('finfo')) {
                $finfo = new \finfo(FILEINFO_MIME);
                $type = $finfo->file($file);
            } else {
                $type = MimeType::getTypeByExt(pathinfo($file, PATHINFO_EXTENSION));
            }
        }
        $type = strstr($type, ';', true) ?: $type;

        return isset(MimeType::$internalType[$type]) ? MimeType::$internalType[$type] : $type;
    }
1335689
public static function getMimeType($tmpName) {

    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mimeType = finfo_file($finfo, $tmpName);

    return $mimeType;
  }
343244
public function parseEncodedBinary()
    {
        $f = ord($this->read(1));
        if ($f <= 250) {
            return $f;
        }
        if ($f === 251) {
            return null;
        }
        if ($f === 255) {
            return false;
        }
        if ($f === 252) {
            return Binary::bytes2int($this->read(2), true);
        }
        if ($f === 253) {
            return Binary::bytes2int($this->read(3), true);
        }
        return Binary::bytes2int($this->read(8), true);
    }
641145
public function getBinary(): string
    {
        if (is_null($this->bin)) {
            $paths = array('/usr/bin/assimp', '/usr/local/bin/assimp', '~/bin/assimp');
            foreach ($paths as $path) {
                try {
                    $this->setBinary($path);
                } catch (\InvalidArgumentException $e) {}
            }

            if (!$this->bin) {
                throw new \RuntimeException('assimp-binary not found in '.explode(', ', $paths), ErrorCodes::FILE_NOT_FOUND);
            }

            if (!is_executable($this->bin)) {
                throw new \RuntimeException('Found a binary file, but it is not executable: '.$this->bin, ErrorCodes::FILE_NOT_EXECUTABLE);
            }
        }
        return $this->bin;
    }
970066
private function binDecode($binary, $min, $max)
        {
            $mid = ($min + $max) / 2;

            if (strlen($binary) == 0) return $mid;

            $bit = substr($binary,0,1);
            $binary = substr($binary,1);

            if ($bit == 1) return $this->binDecode($binary, $mid, $max);
            else return $this->binDecode($binary, $min, $mid);
        }
1266607
protected function getMimeType($file)
    {
        $info = finfo_open(FILEINFO_MIME_TYPE);
        $mime = finfo_file($info, $file);
        finfo_close($info);

        return $mime;
    }
252959
public function binary(): string
    {
        $hex = str_pad($this->numeric(16), static::NB_BITS / 4, '0', STR_PAD_LEFT);

        return pack('H*', $hex);
    }
1166471
public function initFromBinary($binary)
    {
        $resource = @imagecreatefromstring($binary);

        if ($resource === false) {
             throw new \Hail\Image\Exception\NotReadableException(
                "Unable to init from given binary data."
            );
        }

        $image = $this->initFromGdResource($resource);
        $image->mime = MimeType::getMimeTypeByContent($binary);

        return $image;
    }
1208827
public function setBinaryString(BinaryIterator $binary)
    {
        $iterator = new \MultipleIterator(\MultipleIterator::MIT_NEED_ALL|\MultipleIterator::MIT_KEYS_ASSOC);
        $iterator->attachIterator(new RectIterator($this->width, $this->height), 'rect');
        $iterator->attachIterator($binary, 'bin');

        foreach ($iterator as $current) {
            $this->setPixel($current['rect'][0], $current['rect'][1], $current['bin']);
        }

        return $this;
    }
1358794
protected function decode($binary)
    {
        $hex = bin2hex($binary);
        $this->signature = chr(hexdec(substr($hex, 0, 2)));
        $this->userPrivilege = hexdec(substr($hex, 2, 2));
        $this->callbackPhoneNumber = substr($hex, 4, 48);
    }
94494
public static function typeFromMimetype($mime)
    {
        foreach (static::types() as $type => $mimetypes) {
            if (array_search($mime, $mimetypes) !== false) {
                return $type;
            }
        }
    }
1044958
public function buildLenEncodedBinary($s)
    {
        if ($s === null) {
            return "\251";
        }

        $l = mb_orig_strlen($s);

        if ($l <= 250) {
            return chr($l) . $s;
        }

        if ($l <= 0xFFFF) {
            return "\252" . Binary::int2bytes(2, true) . $s;
        }

        if ($l <= 0xFFFFFF) {
            return "\254" . Binary::int2bytes(3, true) . $s;
        }

        return Binary::int2bytes(8, $l, true) . $s;
    }
1317742
protected function decodeMessage($binary, array $options = [])
    {
        $resolver = new OptionsResolver();
        $this->encoder->setDefaultOptions($resolver);
        $options = $resolver->resolve($options);

        return $this->encoder->decode($binary, $this->compressor, $options);
    }