Completed
Push — master ( 4881a6...a1d3b0 )
by Nikola
01:14
created

AbstractOptions::normalize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MonologFactory\Options;
6
7
abstract class AbstractOptions
8
{
9
    /** @var array */
10
    protected $options;
11
    
12 29
    protected function __construct(array $options)
13
    {
14 29
        $this->options = $options;
15 29
    }
16
    
17 33
    public static function fromArray(array $options)
18
    {
19 33
        static::validate($options);
20
21 29
        return new static($options);
22
    }
23
24 22
    public function toArray(): array
25
    {
26 22
        return $this->options;
27
    }
28
29 13
    protected static function validate(array $options): void
30
    {
31 13
    }
32
33 23
    final protected function get(string $key, $default = null)
34
    {
35 23
        return array_key_exists($key, $this->options)
36 17
            ? $this->options[$key]
37 23
            : $default;
38
    }
39
}
40