daux.io/libs/Server/ExtensionMimeTypeGuesser.php

43 lines
931 B
PHP
Raw Normal View History

2017-12-08 16:29:44 +01:00
<?php namespace Todaymade\Daux\Server;
2019-08-07 18:55:18 +02:00
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as FileMimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
2017-12-08 16:29:44 +01:00
/**
* Guesses the mime type using the file's extension
*/
2019-08-07 18:55:18 +02:00
class ExtensionMimeTypeGuesser implements FileMimeTypeGuesserInterface, MimeTypeGuesserInterface
2017-12-08 16:29:44 +01:00
{
/**
* {@inheritdoc}
*/
public function guess($path)
{
$extension = pathinfo($path,PATHINFO_EXTENSION);
if ($extension == "css") {
return "text/css";
}
if ($extension == "js") {
return "application/javascript";
}
}
2019-08-07 18:55:18 +02:00
/**
* {@inheritdoc}
*/
public function isGuesserSupported(): bool
{
return true;
}
/**
* {@inheritdoc}
*/
public function guessMimeType(string $path): ?string
{
return $this->guess($path);
}
2017-12-08 16:29:44 +01:00
}