RegisterAlertersPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 14
loc 14
ccs 11
cts 11
cp 1
rs 9.4286
cc 2
eloc 8
nc 2
nop 1
crap 2
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