Passed
Push — master ( ff83e3...5f4a5c )
by Ehsan
03:54
created

AbstractUtility::getConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Botonomous\utility;
4
5
use Botonomous\Config;
6
7
/**
8
 * Class AbstractUtility.
9
 */
10
abstract class AbstractUtility
11
{
12
    private $config;
13
14
    /**
15
     * AbstractUtility constructor.
16
     *
17
     * @param Config|null $config
18
     */
19 141
    public function __construct(Config $config = null)
20
    {
21 141
        if ($config !== null) {
22 16
            $this->setConfig($config);
23
        }
24 141
    }
25
26
    /**
27
     * @return Config
28
     */
29 33
    public function getConfig()
30
    {
31 33
        if ($this->config === null) {
32 17
            $this->config = new Config();
33
        }
34
35 33
        return $this->config;
36
    }
37
38
    /**
39
     * @param Config $config
40
     */
41 16
    public function setConfig(Config $config)
42
    {
43 16
        $this->config = $config;
44 16
    }
45
}
46