Passed
Pull Request — master (#2)
by mon
03:19
created

Extension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDefaultType() 0 9 2
1
<?php
2
3
namespace FileEye\MimeMap;
4
5
/**
6
 * Class for mapping file extensions to MIME types.
7
 */
8
class Extension
9
{
10
    /**
11
     * Returns a file extension's MIME type.
12
     *
13
     * @param string $extension File extension to get the type of.
14
     *
15
     * @return string Extension's MIME type on success.
16
     */
17 3
    public function getDefaultType($extension)
18
    {
19 3
        $map = new TypeExtensionMap();
20 3
        $extension = strtolower($extension);
21 3
        if (!isset($map->get()['extensions'][$extension])) {
22 1
            throw new \RuntimeException("Sorry, couldn't determine file type.");
23
        }
24 2
        return $map->get()['extensions'][$extension][0];
25
    }
26
}
27