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

GacelaConfigExtender::extend()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 8
c 0
b 0
f 0
nc 4
nop 1
dl 0
loc 15
ccs 9
cts 9
cp 1
crap 4
rs 10
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