Completed
Pull Request — master (#84)
by Alessandro
02:34
created

CoverageConfiguration   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 51
Duplicated Lines 31.37 %

Coupling/Cohesion

Components 0
Dependencies 14

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 0
cbo 14
dl 16
loc 51
ccs 30
cts 30
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadYamlConfiguration() 0 7 1
D loadPostCompileSettings() 16 40 8

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 Paraunit\Configuration;
4
5
use Paraunit\Coverage\CoverageResult;
6
use Paraunit\Coverage\Processor\Clover;
7
use Paraunit\Coverage\Processor\Crap4j;
8
use Paraunit\Coverage\Processor\Html;
9
use Paraunit\Coverage\Processor\Php;
10
use Paraunit\Coverage\Processor\Text;
11
use Paraunit\Coverage\Processor\TextToConsole;
12
use Paraunit\Coverage\Processor\Xml;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
16
/**
17
 * Class CoverageConfiguration
18
 * @package Paraunit\Configuration
19
 */
20
class CoverageConfiguration extends ParallelConfiguration
21
{
22 8
    protected function loadYamlConfiguration(ContainerBuilder $containerBuilder)
23
    {
24 8
        $yamlLoader = parent::loadYamlConfiguration($containerBuilder);
25 8
        $yamlLoader->load('coverage.yml');
26 8
        $yamlLoader->load('coverage_configuration.yml');
27 8
        $yamlLoader->load('coverage_process.yml');
28 8
    }
29
30 8
    protected function loadPostCompileSettings(ContainerBuilder $container, InputInterface $input)
31
    {
32
        /** @var CoverageResult $coverageResult */
33 8
        $coverageResult = $container->get('paraunit.coverage.coverage_result');
34
35 8
        if ($input->getOption('clover')) {
36 1
            $clover = new Clover(new OutputFile($input->getOption('clover')));
37 1
            $coverageResult->addCoverageProcessor($clover);
38
        }
39
40 8 View Code Duplication
        if ($input->getOption('xml')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
41 1
            $xml = new Xml(new OutputPath($input->getOption('xml')));
42 1
            $coverageResult->addCoverageProcessor($xml);
43
        }
44
45 8 View Code Duplication
        if ($input->getOption('html')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
46 1
            $html = new Html(new OutputPath($input->getOption('html')));
47 1
            $coverageResult->addCoverageProcessor($html);
48
        }
49
50 8 View Code Duplication
        if ($input->getOption('text')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
51 1
            $text = new Text(new OutputFile($input->getOption('text')));
52 1
            $coverageResult->addCoverageProcessor($text);
53
        }
54
55 8
        if ($input->getOption('text-to-console')) {
56 1
            $textToConsole = new TextToConsole();
57 1
            $coverageResult->addCoverageProcessor($textToConsole);
58
        }
59
60 8
        if ($input->getOption('crap4j')) {
61 1
            $crap4j = new Crap4j(new OutputFile($input->getOption('crap4j')));
62 1
            $coverageResult->addCoverageProcessor($crap4j);
63
        }
64
65 8 View Code Duplication
        if ($input->getOption('php')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
66 1
            $php = new Php(new OutputFile($input->getOption('php')));
67 1
            $coverageResult->addCoverageProcessor($php);
68
        }
69 8
    }
70
}
71