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

ConfigurationAbstract::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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
}