Completed
Push — master ( 5524a5...bc12da )
by Jeroen
54:06 queued 48:17
created

ParserCompilerPass::process()   B

Complexity

Conditions 6
Paths 10

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 6.0073

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 16
cts 17
cp 0.9412
rs 8.8337
c 0
b 0
f 0
cc 6
nc 10
nop 1
crap 6.0073
1
<?php
2
3
namespace Kunstmaan\FixturesBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class ParserCompilerPass implements CompilerPassInterface
10
{
11
    /**
12
     * @param ContainerBuilder $container
13
     */
14 1
    public function process(ContainerBuilder $container)
15
    {
16 1
        if (!$container->hasDefinition('kunstmaan_fixtures.parser.parser')) {
17
            return;
18
        }
19
20 1
        $definition = $container->getDefinition('kunstmaan_fixtures.parser.parser');
21 1
        $taggedServices = $container->findTaggedServiceIds('kunstmaan_fixtures.parser.property');
22
23 1
        foreach ($taggedServices as $id => $tagAttributes) {
24 1
            foreach ($tagAttributes as $attributes) {
25 1
                $definition->addMethodCall(
26 1
                    'addParser',
27 1
                    array(new Reference($id), $attributes['alias'])
28
                );
29
            }
30
        }
31
32 1
        $taggedServices = $container->findTaggedServiceIds('kunstmaan_fixtures.parser.spec');
33
34 1
        foreach ($taggedServices as $id => $tagAttributes) {
35 1
            foreach ($tagAttributes as $attributes) {
36 1
                $definition->addMethodCall(
37 1
                    'addSpecParser',
38 1
                    array(new Reference($id), $attributes['alias'])
39
                );
40
            }
41
        }
42 1
    }
43
}
44