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