Issues (33)

src/PathFinder.php (2 issues)

1
<?php
2
declare(strict_types=1);
3
4
namespace Utilities\Router;
5
6
use Utilities\Router\Utils\MimeType;
7
8
/**
9
 * PathFinder class
10
 *
11
 * @link    https://github.com/utilities-php/router
12
 * @author  Shahrad Elahi (https://github.com/shahradelahi)
13
 * @license https://github.com/utilities-php/router/blob/master/LICENSE (MIT License)
14
 */
15
class PathFinder
16
{
17
18
    /**
19
     * @param string $filePath pass the file path or file name or extension
20
     * @return string
21
     */
22
    public static function getMimeType(string $filePath): string
23
    {
24
        $extension = pathinfo($filePath, PATHINFO_EXTENSION);
25
        $mime = MimeType::get($extension);
0 ignored issues
show
It seems like $extension can also be of type array; however, parameter $extension of Utilities\Router\Utils\MimeType::get() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
        $mime = MimeType::get(/** @scrutinizer ignore-type */ $extension);
Loading history...
26
        return $mime !== false ? $mime : 'text/plain';
0 ignored issues
show
The condition $mime !== false is always false.
Loading history...
27
    }
28
29
}