CRUDlex\MimeTypes::getMimeTypeByFileInfo PHP Method

getMimeTypeByFileInfo() public method

Gets the mime type by looking at the file info.
public getMimeTypeByFileInfo ( string $file ) : mixed | string
$file string the file to get the mimetype from
return mixed | string the mimetype
    public function getMimeTypeByFileInfo($file)
    {
        // Some wrong read mimetypes
        $fallBack = ['css', 'js'];
        $extension = pathinfo($file, PATHINFO_EXTENSION);
        if (in_array(strtolower($extension), $fallBack)) {
            return $this->getMimeTypeByExtension($file);
        }
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($finfo, $file);
        finfo_close($finfo);
        return $mimeType;
    }