Completed
Push — master ( 65b001...744dd5 )
by Westin
05:31
created

src/Config/ConfigurationAbstract.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 View Code Duplication
    protected function validateConfig($config)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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