Logger::__construct()   B
last analyzed

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
 * Webino™ (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoConfigLib\Feature;
12
13
use WebinoConfigLib\Exception;
14
15
/**
16
 * Class Logger
17
 */
18
class Logger extends AbstractFeature
19
{
20
    /**
21
     * Custom name
22
     */
23
    const NAME = null;
24
25
    /**
26
     * @param string|array|null $name
27
     * @param AbstractFeature[] $features
28
     */
29
    public function __construct($name = null, array $features = [])
30
    {
31
        parent::__construct();
32
33
        if (is_array($name)) {
34
            $features = $name;
35
            $name = $this::NAME;
36
        }
37
38
        if (!$name || (!is_string($name) && !is_array($name))) {
39
            throw (new Exception\InvalidArgumentException(
40
                'Expected name argument as string or overridden const NAME but got %s'
41
            ))->format($name);
42
        }
43
44
        foreach ($features as $feature) {
45
            $this->mergeArray([AbstractLog::KEY => [$name => current($feature->toArray())]]);
46
        }
47
    }
48
}
49