RegisterMetadataFactoriesPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 24
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 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 RegisterMetadataFactoriesPass implements CompilerPassInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 4
    public function process(ContainerBuilder $container)
19
    {
20 4
        $definition = $container->getDefinition('innmind_neo4j.metadata_builder');
21 4
        $ids = $container->findTaggedServiceIds('innmind_neo4j.metadata_factory');
22 4
        $services = [];
23
24 4
        foreach ($ids as $id => $tags) {
25 4
            foreach ($tags as $tag) {
26 4
                if (!isset($tag['type'])) {
27
                    throw new RuntimeException(
28
                        'The type attribute must be defined'
29
                    );
30
                }
31
32 4
                $services[$tag['type']] = new Reference($id);
33
            }
34
        }
35
36 4
        $definition->replaceArgument(1, $services);
37 4
    }
38
}
39