Completed
Push — master ( a1d3b0...f47b8c )
by Nikola
02:43
created

BaseConfig   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 24
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A filter() 0 8 1
A defaults() 0 4 1
validate() 0 1 ?
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MonologFactory\Config;
6
7
use MonologFactory\Exception\InvalidConfig;
8
9
abstract class BaseConfig
10
{
11
    /**
12
     * @throws InvalidConfig
13
     */
14 16
    final protected static function filter(array $config): array
15
    {
16 16
        $config = array_merge(static::defaults(), $config);
17
18 16
        static::validate($config);
19
20 12
        return $config;
21
    }
22
23
    protected static function defaults(): array
24
    {
25
        return [];
26
    }
27
28
    /**
29
     * @throws InvalidConfig
30
     */
31
    abstract protected static function validate(array $config): void;
32
}
33