Completed
Pull Request — master (#75)
by Vladimir
02:42
created

MimeDetector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 102
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMimeType() 0 4 2
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Server;
9
10
class MimeDetector
11
{
12
    private static $mimes = [
13
        'hqx' => 'application/mac-binhex40',
14
        'cpt' => 'application/mac-compactpro',
15
        'csv' => 'text/x-comma-separated-values',
16
        'bin' => 'application/macbinary',
17
        'dms' => 'application/octet-stream',
18
        'lha' => 'application/octet-stream',
19
        'lzh' => 'application/octet-stream',
20
        'exe' => 'application/octet-stream',
21
        'class' => 'application/octet-stream',
22
        'psd' => 'application/x-photoshop',
23
        'so' => 'application/octet-stream',
24
        'sea' => 'application/octet-stream',
25
        'dll' => 'application/octet-stream',
26
        'oda' => 'application/oda',
27
        'pdf' => 'application/pdf',
28
        'ai' => 'application/postscript',
29
        'eps' => 'application/postscript',
30
        'ps' => 'application/postscript',
31
        'smi' => 'application/smil',
32
        'smil' => 'application/smil',
33
        'mif' => 'application/vnd.mif',
34
        'xls' => 'application/excel',
35
        'ppt' => 'application/powerpoint',
36
        'wbxml' => 'application/wbxml',
37
        'wmlc' => 'application/wmlc',
38
        'dcr' => 'application/x-director',
39
        'dir' => 'application/x-director',
40
        'dxr' => 'application/x-director',
41
        'dvi' => 'application/x-dvi',
42
        'gtar' => 'application/x-gtar',
43
        'gz' => 'application/x-gzip',
44
        'php' => 'application/x-httpd-php',
45
        'php4' => 'application/x-httpd-php',
46
        'php3' => 'application/x-httpd-php',
47
        'phtml' => 'application/x-httpd-php',
48
        'phps' => 'application/x-httpd-php-source',
49
        'js' => 'application/x-javascript',
50
        'swf' => 'application/x-shockwave-flash',
51
        'sit' => 'application/x-stuffit',
52
        'tar' => 'application/x-tar',
53
        'tgz' => 'application/x-tar',
54
        'xhtml' => 'application/xhtml+xml',
55
        'xht' => 'application/xhtml+xml',
56
        'zip' => 'application/x-zip',
57
        'mid' => 'audio/midi',
58
        'midi' => 'audio/midi',
59
        'mpga' => 'audio/mpeg',
60
        'mp2' => 'audio/mpeg',
61
        'mp3' => 'audio/mpeg',
62
        'aif' => 'audio/x-aiff',
63
        'aiff' => 'audio/x-aiff',
64
        'aifc' => 'audio/x-aiff',
65
        'ram' => 'audio/x-pn-realaudio',
66
        'rm' => 'audio/x-pn-realaudio',
67
        'rpm' => 'audio/x-pn-realaudio-plugin',
68
        'ra' => 'audio/x-realaudio',
69
        'rv' => 'video/vnd.rn-realvideo',
70
        'wav' => 'audio/x-wav',
71
        'bmp' => 'image/bmp',
72
        'gif' => 'image/gif',
73
        'jpeg' => 'image/jpeg',
74
        'jpg' => 'image/jpeg',
75
        'jpe' => 'image/jpeg',
76
        'png' => 'image/png',
77
        'tiff' => 'image/tiff',
78
        'tif' => 'image/tiff',
79
        'css' => 'text/css',
80
        'html' => 'text/html',
81
        'htm' => 'text/html',
82
        'shtml' => 'text/html',
83
        'txt' => 'text/plain',
84
        'text' => 'text/plain',
85
        'log' => 'text/plain',
86
        'rtx' => 'text/richtext',
87
        'rtf' => 'text/rtf',
88
        'xml' => 'text/xml',
89
        'xsl' => 'text/xml',
90
        'mpeg' => 'video/mpeg',
91
        'mpg' => 'video/mpeg',
92
        'mpe' => 'video/mpeg',
93
        'qt' => 'video/quicktime',
94
        'mov' => 'video/quicktime',
95
        'avi' => 'video/x-msvideo',
96
        'movie' => 'video/x-sgi-movie',
97
        'doc' => 'application/msword',
98
        'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
99
        'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
100
        'word' => 'application/msword',
101
        'xl' => 'application/excel',
102
        'eml' => 'message/rfc822',
103
        'json' => 'application/json',
104
        'svg' => 'image/svg+xml',
105
    ];
106
107
    public static function getMimeType($extension)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
108
    {
109
        return isset(self::$mimes[$extension]) ? self::$mimes[$extension] : null;
110
    }
111
}
112