src/Bundle/Common/File/MimeType/MimeType.php
public function guess(string $path): string
    {
        if (!is_file($path)) {
            throw new FileNotFoundException($path);
        }

        if (!is_readable($path)) {
            throw new AccessDeniedException($path);
        }

        if (0 == count($this->guesserList)) {
            $msg = 'Unable to guess the mime type as no guessers are available';
            if (!FileInfoMimeType::isSupported()) {
                $msg .= ' (Did you enable the php_fileinfo extension?)';
            }
            throw new \LogicException($msg);
        }

        /** @var FileInfoMimeType|BinaryMimeType $guesser */
        foreach ($this->guesserList as $guesser) {
            if ('' != $mimeType = $guesser->guess($path)) {
                return $mimeType;
            }
        }

        return '';
    }
public function guess(string $path): string
    {
        if (!is_file($path)) {
            throw new FileNotFoundException($path);
        }

        if (!is_readable($path)) {
            throw new AccessDeniedException($path);
        }

        if (0 == count($this->guesserList)) {
            $msg = 'Unable to guess the mime type as no guessers are available';
            if (!FileInfoMimeType::isSupported()) {
                $msg .= ' (Did you enable the php_fileinfo extension?)';
            }
            throw new \LogicException($msg);
        }

        /** @var FileInfoMimeType|BinaryMimeType $guesser */
        foreach ($this->guesserList as $guesser) {
            if ('' != $mimeType = $guesser->guess($path)) {
                return $mimeType;
            }
        }

        return '';
    }
Get mime type or NULL, if none could be guessed.

@param string $path Path to the file
@return string
@throws \LogicException
@throws FileNotFoundException
@throws AccessDeniedException