Passed
Push — master ( 3c3ffa...a17b3d )
by Stéphane
03:03
created

ExtensionMimeTypeGuesser::guessMimeType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php namespace Todaymade\Daux\Server;
2
3
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as FileMimeTypeGuesserInterface;
4
use Symfony\Component\Mime\MimeTypeGuesserInterface;
5
6
/**
7
 * Guesses the mime type using the file's extension
8
 */
9
class ExtensionMimeTypeGuesser implements FileMimeTypeGuesserInterface, MimeTypeGuesserInterface
0 ignored issues
show
Deprecated Code introduced by DragoonBoots
The interface Symfony\Component\HttpFo...imeTypeGuesserInterface has been deprecated: since Symfony 4.3, use {@link MimeTypesInterface} instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

9
class ExtensionMimeTypeGuesser implements /** @scrutinizer ignore-deprecated */ FileMimeTypeGuesserInterface, MimeTypeGuesserInterface

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.

Loading history...
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function guess($path)
15
    {
16
        $extension = pathinfo($path,PATHINFO_EXTENSION);
17
18
        if ($extension == "css") {
19
            return "text/css";
20
        }
21
22
        if ($extension == "js") {
23
            return "application/javascript";
24
        }
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function isGuesserSupported(): bool
31
    {
32
        return true;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function guessMimeType(string $path): ?string
39
    {
40
        return $this->guess($path);
41
    }
42
}
43