Config   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 58
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 3
A set() 0 5 1
A has() 0 4 1
A mergeConfig() 0 9 2
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