Completed
Push — master ( 18736d...65af3f )
by Oleg
04:42 queued 21s
created

FileConfigProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 28
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentConfig() 0 11 3
A setCurrentConfig() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\Config;
5
6
final class FileConfigProvider implements CurrentConfigProviderInterface
7
{
8
    /**
9
     * Storage for configs based on name
10
     *
11
     * @var array
12
     */
13
    private $configs = [];
14
15 10
    public function getCurrentConfig(string $className): array
16
    {
17 10
        if (!isset($this->configs[$className])) {
18 10
            if (class_exists($className)) {
19
                $this->configs[$className] = (new $className())();
20
            } else {
21 10
                $this->configs[$className] = [];
22
            }
23
        }
24
25 10
        return $this->configs[$className];
26
    }
27
28
    /**
29
     * @inheritDoc
30
     */
31 10
    public function setCurrentConfig(string $className, array $config): void
32
    {
33 10
        $this->configs[$className] = $config;
34 10
    }
35
}
36