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

Configuration::getOption()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 5
cts 6
cp 0.8333
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 2
crap 3.0416
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