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

FileConfigProvider::setCurrentConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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