Get mimetype of the given file.
```php
$result = FileHelper::mimetypeFile('/var/www/phpunit.xml');
// $result wiil be: 'application/xml'
```

@param  string $path Path to the file.

@return string|null
485057
public static function mimetypeFile ($path)
		{
			$finfo = finfo_open(FILEINFO_MIME_TYPE);
			if ($finfo)
			{
				$info = finfo_file($finfo, $path);
				finfo_close($finfo);

				return $info;
			}

			return null;
		}
212242
public function getMimeType(string $path): string
    {
        $path = $this->normalizePath($path);
        $this->assertPresent($path);

        return $this->getAdapter()->getMimeType($path);
    }
448321
public function getMimetype($path)
    {
        $stat = $this->getMetadata($path);

        if ( $stat && !empty($stat['custom_headers']) && !empty($stat['custom_headers']['Content-Type'])) {
            return ['mimetype' => $stat['custom_headers']['Content-Type']];
        }

        return ['mimetype' => ''];
    }
636340
protected static function _findMimeType($mimeType) {
        if ($mimeType instanceof File) {
            $mimeType = $mimeType->type();

        } else if (strpos($mimeType, '/') === false) {
            $mimeType = self::getTypeFromExt($mimeType);
        }

        return $mimeType;
    }
517688
public function getMimetype($path)
    {
        $meta = $this->getMetadata($path);

        return isset($meta['ContentType'])
            ? ['mimetype' => $meta['ContentType']] : false;
    }
32253
public static function guessMimeType($path, $content)
    {
        $mimeType = MimeType::detectByContent($content);

        if ( ! (empty($mimeType) || in_array($mimeType, ['application/x-empty', 'text/plain', 'text/x-asm']))) {
            return $mimeType;
        }

        return MimeType::detectByFilename($path);
    }
1141110
public function detectMimeType($file = null) {
		// Attempts to retrieve file info from FINFO
		// If FINFO functions are not available then try to retrieve MIME type from pre-defined MIMEs
		// If MIME type doesn't exist, then try (as a last resort) to use the (deprecated) mime_content_type function
		// If all else fails, just return application/octet-stream
		if (!function_exists('finfo_open')) {
			if (function_exists('mime_content_type')) {
				$type = mime_content_type($file);
				if (!empty($type)) {
					return $type;
				}
			}
			$extension = $this->_getExtension($file);
			$mimeType = $this->getMimeTypeByAlias($extension);
			if ($mimeType) {
				return $mimeType;
			}
			return 'application/octet-stream';
		}
		return $this->_detectMimeType($file);
	}
1023436
final public function guessMimeType($path)
    {
        //@NOTE: The github API does not return a MIME type, so we have to guess :-(
        $meta = $this->getMetaData($path);

        if ($this->hasKey($meta, self::KEY_TYPE) && $meta[self::KEY_TYPE] === self::KEY_DIRECTORY) {
            $mimeType = self::MIME_TYPE_DIRECTORY; // or application/x-directory
        } else {
            $content = $this->getFileContents($path);
            $mimeType = MimeType::detectByContent($content);
        }

        return $mimeType;
    }
572973
final public static function get_mimetype(
		string $fname, string $path_to_file=null
	) {

		if (null === $mime = self::_mime_extension($fname))
			return self::_mime_magic($fname, $path_to_file);
		return $mime;
	}
407621
public function getMimeType(): ?string
	{
		$info = finfo_open(FILEINFO_MIME_TYPE);

		$mime = finfo_file($info, $this->getPathname());

		finfo_close($info);

		return $mime ?: null;
	}
177569
public static function getMagicType($file_path) {
		$file_info = finfo_open(FILEINFO_MIME_TYPE);
		$mime_type = finfo_file($file_info, $file_path);
		finfo_close($file_info);

		// Only return valid types, in order to maintain circular compatibility between methods.
		if (static::hasType($mime_type)) {
			return $mime_type;
		}
	}
562159
public function getMimetype($filePath)
    {
        $mimeType = $this->getFileSystem()->getMimetype($filePath);

        $pathParts = pathinfo($filePath);
        if (isset($pathParts['extension'])) {
            //manage bugs in finfo
            switch ($pathParts['extension']) {
                case 'js':
                    if ($mimeType === 'text/plain' || $mimeType === 'text/x-asm' || $mimeType === 'text/x-c') {
                        return 'text/javascript';
                    }
                    break;
                case 'css':
                    //for css files mime type can be 'text/plain' due to bug in finfo (see more: https://bugs.php.net/bug.php?id=53035)
                    if ($mimeType === 'text/plain' || $mimeType === 'text/x-asm') {
                        return 'text/css';
                    }
                    break;
                case 'svg':
                    if ($mimeType === 'text/plain') {
                        return 'image/svg+xml';
                    }
                    break;
                case 'mp3':
                    return 'audio/mpeg';
                    break;
            }
        }

        return $mimeType;
    }
658127
public function fromPath($path)
    {
        $mimetype = null;

        if (static::isSupported())
        {
            if (!is_file($path)) {
                throw new \RuntimeException('File not found at '.$path);
            }

            if (!is_readable($path)) {
                throw new \RuntimeException('File not readable at '.$path);
            }

            $mimetype = $this->_getMimetype(strtolower(pathinfo($path, PATHINFO_EXTENSION)));
        }

        return $mimetype;
    }
497021
public static function getType($path)
    {
        if (!is_file($path)) {
            throw new \InvalidArgumentException(sprintf('invalid filename or path "%s"', $path));
        }

        $info = (new \finfo(FILEINFO_MIME))->file($path);

        return substr($info, 0, strpos($info, ';'));
    }
278476
public static function determineBaseFile(string $path)
    {
        $parts = explode('/', static::normalizePath($path));

        while (count($parts)) {
            $currentPath = implode('/', $parts);
            if (@is_file($currentPath)) {
                return $currentPath;
            }
            array_pop($parts);
        }

        return null;
    }
763282
public function getMimeType()
    {
        $mimetypeRepo = new PhpRepository();
        $path = $this->getPathFilename();

        return $mimetypeRepo->findType(pathinfo($path, PATHINFO_EXTENSION)) ?: 'application/octet-stream';
    }
598249
protected function parseMimeType($path, array $headers)
    {
        if (isset($headers['content-type'])) {
            list($mimetype) = explode(';', $headers['content-type'], 2);

            return trim($mimetype);
        }

        // Remove any query strings or fragments.
        list($path) = explode('#', $path, 2);
        list($path) = explode('?', $path, 2);

        return MimeType::detectByFilename($path);
    }