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

ChannelConfig   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 40
loc 40
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A validateConfig() 14 14 3
A getHandlers() 4 4 1
A getProcessors() 4 4 1
A getName() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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