Completed
Push — master ( 500d51...89dece )
by Westin
12s
created

ChannelConfig::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11MonoLog\Config;
5
6
use WShafer\PSR11MonoLog\Exception\MissingConfigException;
7
8 View Code Duplication
class ChannelConfig
9
{
10
    protected $config = [];
11
12 8
    public function __construct(array $config)
13
    {
14 8
        $this->validateConfig($config);
15 8
        $this->config = $config;
16 8
    }
17
18 8
    protected function validateConfig($config)
19
    {
20 8
        if (empty($config)) {
21 1
            throw new MissingConfigException(
22 1
                'No config found'
23
            );
24
        }
25
26 8
        if (empty($config['handlers'])) {
27 1
            throw new MissingConfigException(
28 1
                'No config key of "handlers" found in channel config array.'
29
            );
30
        }
31 8
    }
32
33 1
    public function getHandlers()
34
    {
35 1
        return $this->config['handlers'];
36
    }
37
38 2
    public function getProcessors()
39
    {
40 2
        return $this->config['processors'] ?? [];
41
    }
42
43 2
    public function getName()
44
    {
45 2
        return $this->config['name'] ?? null;
46
    }
47
}
48