2017-12-08 16:29:44 +01:00
|
|
|
<?php namespace Todaymade\Daux\Server;
|
|
|
|
|
2019-08-07 18:55:18 +02:00
|
|
|
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
2017-12-08 16:29:44 +01:00
|
|
|
|
|
|
|
/**
|
2020-04-22 22:24:52 +02:00
|
|
|
* Guesses the mime type using the file's extension.
|
2017-12-08 16:29:44 +01:00
|
|
|
*/
|
2019-11-28 22:36:26 +01:00
|
|
|
class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface
|
2017-12-08 16:29:44 +01:00
|
|
|
{
|
2019-08-07 18:55:18 +02:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function isGuesserSupported(): bool
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function guessMimeType(string $path): ?string
|
|
|
|
{
|
2019-12-07 16:32:38 +01:00
|
|
|
$extension = pathinfo($path, PATHINFO_EXTENSION);
|
2019-11-28 22:36:26 +01:00
|
|
|
|
2020-04-22 22:24:52 +02:00
|
|
|
if ($extension == 'css') {
|
|
|
|
return 'text/css';
|
2019-11-28 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
2020-04-22 22:24:52 +02:00
|
|
|
if ($extension == 'js') {
|
|
|
|
return 'application/javascript';
|
2019-11-28 22:36:26 +01:00
|
|
|
}
|
2019-11-28 22:41:53 +01:00
|
|
|
|
|
|
|
return null;
|
2019-08-07 18:55:18 +02:00
|
|
|
}
|
2017-12-08 16:29:44 +01:00
|
|
|
}
|