Passed
Push — add-with-all-to-modules-list ( 82b81d...0edb38 )
by Chema
03:40
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 94
    public function extend(GacelaConfig $gacelaConfig): void
15
    {
16 94
        $configsToExtend = $gacelaConfig->toTransfer()->getGacelaConfigsToExtend() ?? [];
17
18 94
        if ($configsToExtend === []) {
19 91
            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