ExtensionMimeTypeGuesser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 8
c 2
b 1
f 0
dl 0
loc 26
ccs 6
cts 9
cp 0.6667
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A guessMimeType() 0 13 3
A isGuesserSupported() 0 3 1
1
<?php namespace Todaymade\Daux\Server;
2
3
use Symfony\Component\Mime\MimeTypeGuesserInterface;
4
5
/**
6
 * Guesses the mime type using the file's extension.
7
 */
8
class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 1
    public function isGuesserSupported(): bool
14
    {
15 1
        return true;
16
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 1
    public function guessMimeType(string $path): ?string
22
    {
23 1
        $extension = pathinfo($path, PATHINFO_EXTENSION);
24
25 1
        if ($extension == 'css') {
26 1
            return 'text/css';
27
        }
28
29
        if ($extension == 'js') {
30
            return 'application/javascript';
31
        }
32
33
        return null;
34
    }
35
}
36