| Total Complexity | 6 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class ExtensionMimeTypeDetector implements MimeTypeDetector |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var ExtensionToMimeTypeMap |
||
| 13 | */ |
||
| 14 | private $extensions; |
||
| 15 | |||
| 16 | 24 | public function __construct(ExtensionToMimeTypeMap $extensions = null) |
|
| 19 | 24 | } |
|
| 20 | |||
| 21 | 18 | public function detectMimeType(string $path, $contents): ?string |
|
| 22 | { |
||
| 23 | 18 | return $this->detectMimeTypeFromPath($path); |
|
| 24 | } |
||
| 25 | |||
| 26 | 18 | public function detectMimeTypeFromPath(string $path): ?string |
|
| 27 | { |
||
| 28 | 18 | $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
|
| 29 | |||
| 30 | 18 | return $this->extensions->lookupMimeType($extension); |
|
| 31 | } |
||
| 32 | |||
| 33 | 18 | public function detectMimeTypeFromFile(string $path): ?string |
|
| 36 | } |
||
| 37 | |||
| 38 | 6 | public function detectMimeTypeFromBuffer(string $contents): ?string |
|
| 43 |