Logger   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 19 6
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