Total Complexity | 7 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 86.67% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | class ConfigStorage |
||
15 | { |
||
16 | /** @var self|null */ |
||
17 | protected static $instance = null; |
||
18 | /** @var Config[] */ |
||
19 | private $configs = []; |
||
20 | |||
21 | 63 | public static function getInstance(): self |
|
22 | { |
||
23 | 63 | if (empty(static::$instance)) { |
|
24 | 1 | static::$instance = new self(); |
|
25 | } |
||
26 | 63 | return static::$instance; |
|
27 | } |
||
28 | |||
29 | 1 | protected function __construct() |
|
30 | { |
||
31 | 1 | } |
|
32 | |||
33 | /** |
||
34 | * @codeCoverageIgnore why someone would run that?! |
||
35 | */ |
||
36 | private function __clone() |
||
37 | { |
||
38 | } |
||
39 | |||
40 | 61 | final public function addConfig(Config $config): void |
|
41 | { |
||
42 | 61 | $this->configs[$config->getSourceName()] = $config; |
|
43 | 61 | } |
|
44 | |||
45 | /** |
||
46 | * @param string $sourceName |
||
47 | * @throws MapperException |
||
48 | * @return Config |
||
49 | */ |
||
50 | 25 | final public function getConfig(string $sourceName): Config |
|
56 | } |
||
57 | } |
||
58 |