Test Failed
Push — master ( 2370d0...e06ed5 )
by Westin
03:13
created

ConfigurationAbstract   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A validateConfig() 0 14 3
A getType() 0 4 1
A getOptions() 0 4 1
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
    public function __construct(array $config)
13
    {
14
        $this->validateConfig($config);
15
        $this->config = $config;
16
    }
17
18
    protected function validateConfig($config)
19
    {
20
        if (empty($config)) {
21
            throw new MissingConfigException(
22
                'No config found'
23
            );
24
        }
25
26
        if (empty($config['type'])) {
27
            throw new MissingConfigException(
28
                'No config key of "type" found in adaptor config array.'
29
            );
30
        }
31
    }
32
33
    public function getType()
34
    {
35
        return $this->config['type'];
36
    }
37
38
    public function getOptions()
39
    {
40
        return $this->config['options'] ?? [];
41
    }
42
}