Completed
Push — master ( 6ef701...eb43cb )
by Alessandro
13s
created

CoverageConfiguration   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 53
Duplicated Lines 30.19 %

Coupling/Cohesion

Components 0
Dependencies 14

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
D loadPostCompileSettings() 16 44 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
declare(strict_types=1);
3
4
namespace Paraunit\Configuration;
5
6
use Paraunit\Configuration\DependencyInjection\CoverageContainerDefinition;
7
use Paraunit\Coverage\CoverageResult;
8
use Paraunit\Coverage\Processor\Clover;
9
use Paraunit\Coverage\Processor\Crap4j;
10
use Paraunit\Coverage\Processor\Html;
11
use Paraunit\Coverage\Processor\Php;
12
use Paraunit\Coverage\Processor\Text;
13
use Paraunit\Coverage\Processor\TextToConsole;
14
use Paraunit\Coverage\Processor\Xml;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
19
/**
20
 * Class CoverageConfiguration
21
 * @package Paraunit\Configuration
22
 */
23
class CoverageConfiguration extends ParallelConfiguration
24
{
25 11
    public function __construct()
26
    {
27 11
        parent::__construct();
28 11
        $this->containerDefinition = new CoverageContainerDefinition();
29
    }
30
31 11
    protected function loadPostCompileSettings(ContainerBuilder $container, InputInterface $input)
32
    {
33 11
        parent::loadPostCompileSettings($container, $input);
34
35
        /** @var CoverageResult $coverageResult */
36 11
        $coverageResult = $container->get(CoverageResult::class);
37
38 11
        if ($input->getOption('clover')) {
39 1
            $clover = new Clover(new OutputFile($input->getOption('clover')));
40 1
            $coverageResult->addCoverageProcessor($clover);
41
        }
42
43 11 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...
44 1
            $xml = new Xml(new OutputPath($input->getOption('xml')));
45 1
            $coverageResult->addCoverageProcessor($xml);
46
        }
47
48 11 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...
49 1
            $html = new Html(new OutputPath($input->getOption('html')));
50 1
            $coverageResult->addCoverageProcessor($html);
51
        }
52
53 11 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...
54 1
            $text = new Text(new OutputFile($input->getOption('text')));
55 1
            $coverageResult->addCoverageProcessor($text);
56
        }
57
58 11
        if ($input->getOption('text-to-console')) {
59
            /** @var OutputInterface $output */
60 2
            $output = $container->get(OutputInterface::class);
61 2
            $textToConsole = new TextToConsole($output, (bool)$input->getOption('ansi'));
62 2
            $coverageResult->addCoverageProcessor($textToConsole);
63
        }
64
65 11
        if ($input->getOption('crap4j')) {
66 1
            $crap4j = new Crap4j(new OutputFile($input->getOption('crap4j')));
67 1
            $coverageResult->addCoverageProcessor($crap4j);
68
        }
69
70 11 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...
71 1
            $php = new Php(new OutputFile($input->getOption('php')));
72 1
            $coverageResult->addCoverageProcessor($php);
73
        }
74
    }
75
}
76