ChannelConfig::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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