RegisterIdentityGeneratorsPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 20 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Neo4jBundle\DependencyInjection\Compiler;
5
6
use Innmind\Neo4jBundle\Exception\LogicException;
7
use Symfony\Component\DependencyInjection\{
8
    Compiler\CompilerPassInterface,
9
    ContainerBuilder,
10
    Reference
11
};
12
13
final class RegisterIdentityGeneratorsPass implements CompilerPassInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 6
    public function process(ContainerBuilder $container)
19
    {
20 6
        $ids = $container->findTaggedServiceIds('innmind_neo4j.identity.generator');
21 6
        $definition = $container->getDefinition('innmind_neo4j.generators');
22 6
        $generators = [];
23
24 6
        foreach ($ids as $id => $tags) {
25 4
            foreach ($tags as $attributes) {
26 4
                if (!isset($attributes['generates'])) {
27 2
                    throw new LogicException(sprintf(
28 2
                        'The "generates" attribute must be set for "%s"',
29 2
                        $id
30
                    ));
31
                }
32
33 2
                $generators[$attributes['generates']] = new Reference($id);
34
            }
35
        }
36
37 4
        $definition->replaceArgument(2, $generators);
38 4
    }
39
}
40