ConfigurationAbstract::getOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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