Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

PopulatorCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 24
loc 24
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 18 18 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 PopulatorCompilerPass 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.populator.populator');
21 1
        $taggedServices = $container->findTaggedServiceIds('kunstmaan_fixtures.populator');
22
23 1
        foreach ($taggedServices as $id => $tagAttributes) {
24 1
            foreach ($tagAttributes as $attributes) {
25 1
                $definition->addMethodCall(
26 1
                    'addPopulator',
27 1
                    [new Reference($id), $attributes['alias']]
28
                );
29
            }
30
        }
31 1
    }
32
}
33