Completed
Pull Request — master (#118)
by Filip
24:11 queued 22:16
created

Configuration   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 77.78%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A merge() 0 4 1
A replace() 0 4 1
A setOption() 0 4 1
A getOption() 0 12 3
1
<?php
2
3
namespace League\HTMLToMarkdown;
4
5
class Configuration
6
{
7
    protected $config;
8
9
    /**
10
     * @param array $config
11
     */
12 87
    public function __construct(array $config = array())
13
    {
14 87
        $this->config = $config;
15 87
    }
16
17
    /**
18
     * @param array $config
19
     */
20 81
    public function merge(array $config = array())
21
    {
22 81
        $this->config = array_replace_recursive($this->config, $config);
23 81
    }
24
25
    /**
26
     * @param array $config
27
     */
28
    public function replace(array $config = array())
29
    {
30
        $this->config = $config;
31
    }
32
33
    /**
34
     * @param string $key
35
     * @param mixed  $value
36
     */
37 6
    public function setOption($key, $value)
38
    {
39 6
        $this->config[$key] = $value;
40 6
    }
41
42
    /**
43
     * @param string|null $key
44
     * @param mixed|null  $default
45
     *
46
     * @return mixed|null
47
     */
48 78
    public function getOption($key = null, $default = null)
49
    {
50 78
        if ($key === null) {
51
            return $this->config;
52
        }
53
54 78
        if (!isset($this->config[$key])) {
55 3
            return $default;
56
        }
57
58 75
        return $this->config[$key];
59
    }
60
}
61