Passed
Pull Request — master (#9)
by mon
02:42
created

MapHandler::addMapEntry()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 3
crap 3
1
<?php
2
3
namespace FileEye\MimeMap;
4
5
/**
6
 * Class for managing map singletons.
7
 */
8
abstract class MapHandler
9
{
10
    /**
11
     * The default map PHP class.
12
     */
13
    const DEFAULT_MAP_CLASS = '\FileEye\MimeMap\Map\ApacheMap';
14
15
    /**
16
     * The default map class to use.
17
     *
18
     * It can be overridden by ::setDefaultMapClass.
19
     *
20
     * @var string
21
     */
22
    protected static $defaultMapClass = MapHandler::DEFAULT_MAP_CLASS;
23
24
    /**
25
     * Sets a map class as default for new instances.
26
     *
27
     * @param string $map_class A FQCN.
28
     */
29 1
    public static function setDefaultMapClass($map_class)
30
    {
31 1
        static::$defaultMapClass = $map_class;
32 1
    }
33
34
    /**
35
     * Returns the map instance.
36
     *
37
     * @param string $map
0 ignored issues
show
Bug introduced by
There is no parameter named $map. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
38
     *   (Optional) The map FQCN to be used. If null, the default map will be
39
     *   used.
40
     *
41
     * @return string
42
     */
43 24
    public static function map($map_class = null)
44
    {
45 24
        if (!$map_class) {
46 22
            $map_class = static::$defaultMapClass;
47
        }
48 24
        return $map_class::getInstance();
49
    }
50
}
51