Config::init()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
nc 4
nop 1
dl 0
loc 12
rs 10
c 1
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
namespace Watchmaker;
4
5
use Watchmaker\error\MissingParameterException;
6
7
8
/**
9
 * @property-read string $ansi
10
 * @property-read string $delete
11
 */
12
class Config
13
{
14
    private $ansi = false;
15
    private $delete = false;
16
17
    public function __construct(array $options = array())
18
    {
19
        $this->init($options);
20
    }
21
22
    private function init($options)
23
    {
24
        if (empty($options)) {
25
            return;
26
        }
27
28
        foreach ($options as $key => $val)
29
        {
30
            if (!isset($this->{$key})) {
31
                continue;
32
            }
33
            $this->{$key} = $val;
34
        }
35
    }
36
37
    /**
38
     * @param $get
39
     * @return mixed
40
     * @throws MissingParameterException
41
     */
42
    public function __get($get)
43
    {
44
        if (isset($this->{$get})) {
45
            return $this->{$get};
46
        }
47
48
        throw new MissingParameterException();
49
    }
50
}
51