Config::has()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace FMUP;
3
4
/**
5
 * Class Config
6
 * @package FMUP
7
 */
8
class Config implements Config\ConfigInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    private $params = array();
14
15
    /**
16
     * Retrieve defined param
17
     * @param string $paramName
18
     * @return array|null
19
     */
20 3
    public function get($paramName = null)
21
    {
22 3
        if (true == is_null($paramName)) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
23 2
            return $this->params;
24
        }
25 3
        return $this->has($paramName) ? $this->params[$paramName] : null;
26
    }
27
28
    /**
29
     * Define a param
30
     * @param string $paramName
31
     * @param mixed $value default null
32
     * @return $this
33
     */
34 5
    public function set($paramName, $value = null)
35
    {
36 5
        $this->params[$paramName] = $value;
37 5
        return $this;
38
    }
39
40
    /**
41
     * Merge an array with current config
42
     * @param array $paramArray
43
     * @param bool $before Merge before (default : false)
44
     * @return $this
45
     */
46 1
    public function mergeConfig(array $paramArray = array(), $before = false)
47
    {
48 1
        if ($before) {
49 1
            $this->params = $this->params + $paramArray;
50
        } else {
51 1
            $this->params = $paramArray + $this->params;
52
        }
53 1
        return $this;
54
    }
55
56
    /**
57
     * Is a param defined
58
     * @param string $paramName
59
     * @return bool
60
     */
61 5
    public function has($paramName)
62
    {
63 5
        return isset($this->params[$paramName]);
64
    }
65
}
66