Completed
Pull Request — master (#90)
by Arnaud
12:13 queued 03:07
created

DataProviderCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
dl 19
loc 19
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 3
nop 1
crap 3
1
<?php
2
3
namespace LAG\AdminBundle\DependencyInjection\CompilerPass;
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 DataProviderCompilerPass implements CompilerPassInterface
1 ignored issue
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
     * Add the tagged data provider to the DataProviderFactory.
13
     *
14
     * @param ContainerBuilder $container
15
     */
16 3
    public function process(ContainerBuilder $container)
17
    {
18 3
        if (!$container->has('lag.admin.data_providers_factory')) {
19 2
            return;
20
        }
21
22 1
        $definition = $container->findDefinition('lag.admin.data_providers_factory');
23 1
        $taggedServices = $container->findTaggedServiceIds('data_provider');
24
25 1
        foreach ($taggedServices as $id => $tags) {
26 1
            $definition->addMethodCall(
27 1
                'addDataProvider',
28
                [
29 1
                    $id,
30 1
                    new Reference($id),
31
                ]
32
            );
33
        }
34 1
    }
35
}
36