Completed
Pull Request — master (#90)
by Arnaud
10:09 queued 08:09
created

ResponderCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 18
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 15 15 3

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 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 ResponderCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->has('lag.admin.responder.storage')) {
14
            return;
15
        }
16
        $storage = $container->getDefinition('lag.admin.responder.storage');
17
        $responderIds = $container->findTaggedServiceIds('responder');
18
    
19
        foreach ($responderIds as $responderId => $attributes) {
20
            $storage->addMethodCall('add', [
21
                $responderId,
22
                new Reference($responderId),
23
            ]);
24
        }
25
    }
26
}
27