AdditionalReporterCompilerPass::process()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 6.0359

Importance

Changes 0
Metric Value
dl 17
loc 17
ccs 9
cts 10
cp 0.9
rs 9.0777
c 0
b 0
f 0
cc 6
nc 6
nop 1
crap 6.0359
1
<?php
2
3
namespace Liip\MonitorBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12 View Code Duplication
class AdditionalReporterCompilerPass 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...
13
{
14 3
    public function process(ContainerBuilder $container)
15
    {
16 3
        if (false === $container->hasParameter('liip_monitor.runners')) {
17
            return;
18
        }
19
20 3
        foreach ($container->getParameter('liip_monitor.runners') as $runnerServiceId) {
21 3
            $definition = $container->getDefinition($runnerServiceId);
22
23 3
            foreach ($container->findTaggedServiceIds('liip_monitor.additional_reporter') as $id => $tags) {
24 2
                foreach ($tags as $attributes) {
25 2
                    $alias = empty($attributes['alias']) ? $id : $attributes['alias'];
26 2
                    $definition->addMethodCall('addAdditionalReporter', [$alias, new Reference($id)]);
27
                }
28
            }
29
        }
30 3
    }
31
}
32