utilities-php /
router
| 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); |
||
| 26 | return $mime !== false ? $mime : 'text/plain'; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 27 | } |
||
| 28 | |||
| 29 | } |