Completed
Push — master ( 7ec665...146f6b )
by personal
08:22 queued 05:17
created

QueueReportFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 10.61 %

Coupling/Cohesion

Components 1
Dependencies 12

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 12
dl 7
loc 66
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A factory() 0 18 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
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Hal\Application\Command\Job;
11
use Hal\Application\Extension\ExtensionService;
12
use Hal\Application\Extension\extensionsService;
13
use Hal\Application\Extension\Repository;
14
use Hal\Application\Formater\Chart;
15
use Hal\Application\Formater\Details;
16
use Hal\Application\Formater\Summary;
17
use Hal\Application\Formater\Violations;
18
use Hal\Application\Score\Scoring;
19
use Hal\Component\Aggregator\DirectoryAggregatorFlat;
20
use Hal\Component\Bounds\BoundsInterface;
21
use Hal\Component\Config\ConfigurationInterface;
22
use Hal\Component\File\Finder;
23
use Symfony\Component\Console\Input\InputInterface;
24
use Symfony\Component\Console\Output\OutputInterface;
25
26
/**
27
 * Queue factory
28
 *
29
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
30
 */
31
class QueueReportFactory
32
{
33
34
    /**
35
     * @var ConfigurationInterface
36
     */
37
    private $config;
38
39
    /**
40
     * @var OutputInterface
41
     */
42
    private $output;
43
44
    /**
45
     * @var InputInterface
46
     */
47
    private $input;
48
49
    /**
50
     * @var ExtensionService
51
     */
52
    private $extensionsService;
53
54
    /**
55
     * Constructor
56
     *
57
     * @param InputInterface $input
58
     * @param OutputInterface $output
59
     * @param ConfigurationInterface $config
60
     * @param ExtensionService $extensionsService
61
     */
62 View Code Duplication
    public function __construct(InputInterface $input, OutputInterface $output, ConfigurationInterface $config, ExtensionService $extensionsService)
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...
63
    {
64
        $this->config = $config;
65
        $this->input = $input;
66
        $this->output = $output;
67
        $this->extensionsService = $extensionsService;
68
    }
69
70
    /**
71
     * Factory queue
72
     *
73
     * @param Finder $finder
74
     * @param BoundsInterface $bounds
75
     * @return Queue
76
     */
77
    public function factory(Finder $finder, BoundsInterface $bounds) {
0 ignored issues
show
Unused Code introduced by
The parameter $finder is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
78
        $rules = $this->config->getRuleSet();
79
        $validator = new \Hal\Application\Rule\Validator($rules);
80
81
        // jobs queue planning
82
        $queue = new Queue;
83
        $queue
84
            ->push(new ReportRenderer(true, $this->output, new Summary\Cli($validator, $bounds, $this->output, $this->extensionsService)))
85
            ->push(new ReportRenderer($this->config->getLogging()->getReport('cli'), $this->output, new Details\Cli($validator, $bounds, $this->extensionsService)))
86
            ->push(new ReportWriter($this->config->getLogging()->getReport('html'), $this->output, new Summary\Html($validator, $bounds, $this->config->getTemplate(), $this->extensionsService)))
87
            ->push(new ReportWriter($this->config->getLogging()->getReport('json'), $this->output, new Details\Json(true, $this->extensionsService)))
88
            ->push(new ReportWriter($this->config->getLogging()->getReport('xml'), $this->output, new Summary\Xml($validator, $bounds, $this->extensionsService)))
89
            ->push(new ReportWriter($this->config->getLogging()->getReport('csv'), $this->output, new Details\Csv($this->extensionsService)))
90
            ->push(new ReportWriter($this->config->getLogging()->getViolation('xml'), $this->output, new Violations\Xml($validator, $bounds, $this->extensionsService)))
91
            ->push(new ReportWriter($this->config->getLogging()->getChart('bubbles'), $this->output, new Chart\Bubbles($validator, $bounds, $this->extensionsService)));
0 ignored issues
show
Unused Code introduced by
The call to Bubbles::__construct() has too many arguments starting with $this->extensionsService.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
92
93
        return $queue;
94
    }
95
96
}
97