Passed
Push — main ( fbef6d...0b56a2 )
by Chema
01:16 queued 35s
created

GacelaConfigExtender   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A extend() 0 15 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Bootstrap\Setup;
6
7
use Gacela\Framework\Bootstrap\GacelaConfig;
8
use Gacela\Framework\Container\Container;
9
10
use function is_callable;
11
12
final class GacelaConfigExtender
13
{
14 93
    public function extend(GacelaConfig $gacelaConfig): void
15
    {
16 93
        $configsToExtend = $gacelaConfig->build()['gacela-configs-to-extend'] ?? [];
17
18 93
        if ($configsToExtend === []) {
19 90
            return;
20
        }
21
22 3
        $container = new Container();
23
24 3
        foreach ($configsToExtend as $className) {
25
            /** @var callable|null $configToExtend */
26 3
            $configToExtend = $container->get($className);
27 3
            if (is_callable($configToExtend)) {
28 2
                $configToExtend($gacelaConfig);
29
            }
30
        }
31
    }
32
}
33