Completed
Pull Request — master (#152)
by
unknown
16:45
created

Configuration   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 48
ccs 11
cts 15
cp 0.7332
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 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
    public function replace(array $config = array())
21
    {
22
        $this->config = $config;
23
    }
24
25
    /**
26
     * @param string $key
27
     * @param mixed  $value
28
     */
29 6
    public function setOption($key, $value)
30
    {
31 6
        $this->config[$key] = $value;
32 6
    }
33
34
    /**
35
     * @param string|null $key
36
     * @param mixed|null  $default
37
     *
38
     * @return mixed|null
39
     */
40 81
    public function getOption($key = null, $default = null)
41
    {
42 81
        if ($key === null) {
43
            return $this->config;
44
        }
45
46 81
        if (!isset($this->config[$key])) {
47 3
            return $default;
48
        }
49
50 78
        return $this->config[$key];
51
    }
52
}
53