Test Failed
Push — 1.0.x ( bb4218...35362a )
by Koldo
11:46
created

ToggleAPIPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 11
cp 0
rs 9.9332
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pheature\Community\Symfony\DependencyInjection;
6
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
11
12
final class ToggleAPIPass implements CompilerPassInterface
13
{
14
    public function process(ContainerBuilder $container): void
15
    {
16
        /** @var array<array<mixed>> $pheatureFlagsConfig */
17
        $pheatureFlagsConfig = $container->getExtensionConfig('pheature_flags');
18
19
        $mergedConfig = array_merge(...$pheatureFlagsConfig);
20
21
        if (false === $mergedConfig['api_enabled']) {
22
            return;
23
        }
24
25
        $container->getParameterBag()->set('pheature_flags_prefix', $mergedConfig['api_prefix']);
26
27
        $loader = new YamlFileLoader(
28
            $container,
29
            new FileLocator(__DIR__ . '/../Resources/config/toggle_api')
30
        );
31
        $loader->load('services/controller_services.yaml');
32
        $loader->load('services/handler_services.yaml');
33
    }
34
}
35