AdditionalReporterCompilerPassTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 82.35 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 42
loc 51
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerCompilerPass() 0 4 1
A testProcessWithAlias() 21 21 1
A testProcessWithoutAlias() 21 21 1

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 Liip\MonitorBundle\Tests\DependencyInjection\Compiler;
4
5
use Liip\MonitorBundle\DependencyInjection\Compiler\AdditionalReporterCompilerPass;
6
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Definition;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
/**
12
 * @author Kevin Bond <[email protected]>
13
 */
14
class AdditionalReporterCompilerPassTest extends AbstractCompilerPassTestCase
15
{
16 View Code Duplication
    public function testProcessWithAlias()
0 ignored issues
show
Duplication introduced by
This method 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...
17
    {
18
        $runner = new Definition();
19
        $this->setDefinition('liip_monitor.runner_default', $runner);
20
        $this->setParameter('liip_monitor.runners', ['liip_monitor.runner_default']);
21
22
        $reporter = new Definition();
23
        $reporter->addTag('liip_monitor.additional_reporter', ['alias' => 'foo']);
24
        $this->setDefinition('foo_reporter', $reporter);
25
26
        $this->compile();
27
28
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
29
            'liip_monitor.runner_default',
30
            'addAdditionalReporter',
31
            [
32
                'foo',
33
                new Reference('foo_reporter'),
34
            ]
35
        );
36
    }
37
38 View Code Duplication
    public function testProcessWithoutAlias()
0 ignored issues
show
Duplication introduced by
This method 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...
39
    {
40
        $runner = new Definition();
41
        $this->setDefinition('liip_monitor.runner_default', $runner);
42
        $this->setParameter('liip_monitor.runners', ['liip_monitor.runner_default']);
43
44
        $reporter = new Definition();
45
        $reporter->addTag('liip_monitor.additional_reporter');
46
        $this->setDefinition('foo_reporter', $reporter);
47
48
        $this->compile();
49
50
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
51
            'liip_monitor.runner_default',
52
            'addAdditionalReporter',
53
            [
54
                'foo_reporter',
55
                new Reference('foo_reporter'),
56
            ]
57
        );
58
    }
59
60
    protected function registerCompilerPass(ContainerBuilder $container): void
61
    {
62
        $container->addCompilerPass(new AdditionalReporterCompilerPass());
63
    }
64
}
65