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

FileConfigProvider::getCurrentConfig()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
crap 3.0416
rs 10
c 0
b 0
f 0
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