Completed
Push — master ( 770316...74fc07 )
by Jeroen
09:08 queued 02:44
created

BuilderCompilerPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 11
cts 11
cp 1
rs 9.6666
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
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 View Code Duplication
class BuilderCompilerPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @param ContainerBuilder $container
13
     */
14 2
    public function process(ContainerBuilder $container)
15
    {
16 2
        if (!$container->hasDefinition('kunstmaan_fixtures.builder.builder')) {
17 1
            return;
18
        }
19
20 1
        $definition = $container->getDefinition('kunstmaan_fixtures.builder.builder');
21 1
        $taggedServices = $container->findTaggedServiceIds('kunstmaan_fixtures.builder');
22
23 1
        foreach ($taggedServices as $id => $tagAttributes) {
24 1
            foreach ($tagAttributes as $attributes) {
25 1
                $definition->addMethodCall(
26 1
                    'addBuilder',
27 1
                    array(new Reference($id), $attributes['alias'])
28
                );
29
            }
30
        }
31 1
    }
32
}
33