ConfigurationAbstract   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 35
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getType() 0 4 1
A getOptions() 0 4 1
A validateConfig() 0 14 3
1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11FlySystem\Config;
5
6
use WShafer\PSR11FlySystem\Exception\MissingConfigException;
7
8
abstract class ConfigurationAbstract
9
{
10
    protected $config = [];
11
12 16
    public function __construct(array $config)
13
    {
14 16
        $this->validateConfig($config);
15 16
        $this->config = $config;
16 16
    }
17
18 16
    protected function validateConfig($config)
19
    {
20 16
        if (empty($config)) {
21 2
            throw new MissingConfigException(
22 2
                'No config found'
23
            );
24
        }
25
26 16
        if (empty($config['type'])) {
27 2
            throw new MissingConfigException(
28 2
                'No config key of "type" found in adaptor config array.'
29
            );
30
        }
31 16
    }
32
33 2
    public function getType()
34
    {
35 2
        return $this->config['type'];
36
    }
37
38 2
    public function getOptions()
39
    {
40 2
        return $this->config['options'] ?? [];
41
    }
42
}
43