RegisterRepositoriesPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

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