Completed
Push — prototype ( 942ea2...3bfdd7 )
by Peter
04:02
created

Logger::__construct()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 11
nc 6
nop 2
dl 0
loc 19
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace WebinoConfigLib\Feature;
4
5
use WebinoConfigLib\Exception;
6
7
/**
8
 * Class Logger
9
 */
10
class Logger extends AbstractFeature
11
{
12
    /**
13
     * Custom name
14
     */
15
    const NAME = null;
16
17
    /**
18
     * @param string|array|null $name
19
     * @param AbstractFeature[] $features
20
     */
21
    public function __construct($name = null, array $features = [])
22
    {
23
        parent::__construct([]);
24
25
        if (is_array($name)) {
26
            $features = $name;
27
            $name = $this::NAME;
28
        }
29
30
        if (!$name || (!is_string($name) && !is_array($name))) {
31
            throw (new Exception\InvalidArgumentException(
32
                'Expected name argument as string or overridden const NAME but got %s'
33
            ))->format($name);
34
        }
35
36
        foreach ($features as $feature) {
37
            $this->mergeArray([AbstractLog::KEY => [$name => current($feature->toArray())]]);
38
        }
39
    }
40
}
41