DictionaryFactoryBuildingPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Knp\DictionaryBundle\DependencyInjection\Compiler;
6
7
use Knp\DictionaryBundle\Dictionary\Factory\Aggregate;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
final class DictionaryFactoryBuildingPass implements CompilerPassInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    public const TAG_FACTORY = 'knp_dictionary.factory';
18
19 1
    public function process(ContainerBuilder $containerBuilder): void
20
    {
21 1
        foreach (array_keys($containerBuilder->findTaggedServiceIds(self::TAG_FACTORY)) as $id) {
22
            $containerBuilder
23 1
                ->findDefinition(Aggregate::class)
24 1
                ->addMethodCall('addFactory', [new Reference($id)])
25
            ;
26
        }
27 1
    }
28
}
29