TaggedEnumCollectorCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yokai\EnumBundle\DependencyInjection\CompilerPass;
6
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
/**
12
 * @author Yann Eugoné <[email protected]>
13
 */
14
class TaggedEnumCollectorCompilerPass implements CompilerPassInterface
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public function process(ContainerBuilder $container): void
20
    {
21
        if (!$container->hasDefinition('enum.registry')) {
22
            return;
23
        }
24
25
        $registry = $container->getDefinition('enum.registry');
26
27
        foreach (array_keys($container->findTaggedServiceIds('enum')) as $enum) {
28
            $registry->addMethodCall('add', [new Reference($enum)]);
29
        }
30
    }
31
}
32