RegisterAlertersPass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 17
loc 17
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 14 14 2

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 Innmind\ProvisionerBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Reference;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
9
/**
10
 * Register services tagged as services as object that will
11
 * be notified when an alert is raised
12
 */
13 View Code Duplication
class RegisterAlertersPass 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...
14
{
15 3
    public function process(ContainerBuilder $container)
16
    {
17 3
        $listener = $container->getDefinition('innmind_provisioner.listener.alert');
18 3
        $alerters = $container->findTaggedServiceIds(
19
            'innmind_provisioner.alerter'
20 3
        );
21
22 3
        foreach ($alerters as $id => $attributes) {
23 3
            $listener->addMethodCall(
24 3
                'addAlerter',
25 3
                [new Reference($id)]
26 3
            );
27 3
        }
28 3
    }
29
}
30