Completed
Pull Request — master (#375)
by Paul
06:11
created

DataSourceCompilerPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 12

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
rs 9.0534
cc 4
eloc 12
nc 4
nop 1
1
<?php
2
3
namespace Victoire\Bundle\CriteriaBundle\DependencyInjection\Compiler;
4
5
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10 View Code Duplication
class DataSourceCompilerPass 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...
11
{
12
    /**
13
     * @param ContainerBuilder $container
14
     */
15
    public function process(ContainerBuilder $container)
16
    {
17
18
        if (!$container->hasDefinition('victoire_criteria.chain.data_source_chain')) {
19
            return;
20
        }
21
        $chainDefinition = $container->getDefinition(
22
            'victoire_criteria.chain.data_source_chain'
23
        );
24
        $taggedServices = $container->findTaggedServiceIds(
25
            'victoire_criteria'
26
        );
27
        foreach ($taggedServices as $id => $tagAttributes) {
28
            foreach ($tagAttributes as $attributes) {
29
                $chainDefinition->addMethodCall(
30
                    'addDataSource',
31
                    [new Reference($id), $attributes]
32
                );
33
            }
34
        }
35
    }
36
}
37