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

MimeDetector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

1 Method

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