QueueFactory   C
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 19

Importance

Changes 6
Bugs 1 Features 1
Metric Value
wmc 2
lcom 1
cbo 19
dl 0
loc 63
rs 6.875
c 6
b 1
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A factory() 0 22 1
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\Formater\Chart;
12
use Hal\Application\Formater\Details;
13
use Hal\Application\Formater\Summary;
14
use Hal\Application\Formater\Violations;
15
use Hal\Application\Score\Scoring;
16
use Hal\Component\Aggregator\DirectoryAggregatorFlat;
17
use Hal\Component\Bounds\BoundsInterface;
18
use Hal\Component\Config\ConfigurationInterface;
19
use Hal\Component\File\Finder;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Output\OutputInterface;
22
23
/**
24
 * Queue factory
25
 *
26
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
27
 */
28
class QueueFactory
29
{
30
31
    /**
32
     * @var ConfigurationInterface
33
     */
34
    private $config;
35
36
    /**
37
     * @var OutputInterface
38
     */
39
    private $output;
40
41
    /**
42
     * @var InputInterface
43
     */
44
    private $input;
45
46
    /**
47
     * Constructor
48
     *
49
     * @param InputInterface $input
50
     * @param OutputInterface $output
51
     * @param ConfigurationInterface $config
52
     */
53
    public function __construct(InputInterface $input, OutputInterface $output, ConfigurationInterface $config)
54
    {
55
        $this->config = $config;
56
        $this->input = $input;
57
        $this->output = $output;
58
    }
59
60
    /**
61
     * Factory queue
62
     *
63
     * @param Finder $finder
64
     * @param BoundsInterface $bounds
65
     * @return Queue
66
     */
67
    public function factory(Finder $finder, BoundsInterface $bounds) {
68
        $rules = $this->config->getRuleSet();
69
        $validator = new \Hal\Application\Rule\Validator($rules);
70
71
        // jobs queue planning
72
        $queue = new Queue;
73
        $queue
74
            ->push(new DoAnalyze($this->output, $finder, $this->config->getPath()->getBasePath(), !$this->input->getOption('without-oop'), $this->config->getIgnoreErrors()))
75
            ->push(new SearchBounds($this->output, $bounds))
76
            ->push(new DoAggregatedAnalyze($this->output, new DirectoryAggregatorFlat($this->input->getOption('level'))))
77
            ->push(new CalculateScore(new Scoring($bounds)))
78
            ->push(new ReportRenderer(true, $this->output, new Summary\Cli($validator, $bounds, $this->output)))
79
            ->push(new ReportRenderer($this->config->getLogging()->getReport('cli'), $this->output, new Details\Cli($validator, $bounds)))
80
            ->push(new ReportWriter($this->config->getLogging()->getReport('html'), $this->output, new Summary\Html($validator, $bounds, $this->config->getTemplate())))
81
            ->push(new ReportWriter($this->config->getLogging()->getReport('json'), $this->output, new Details\Json($validator, $bounds)))
0 ignored issues
show
Documentation introduced by
$validator is of type object<Hal\Application\Rule\Validator>, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Unused Code introduced by
The call to Json::__construct() has too many arguments starting with $bounds.

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...
82
            ->push(new ReportWriter($this->config->getLogging()->getReport('xml'), $this->output, new Summary\Xml($validator, $bounds)))
83
            ->push(new ReportWriter($this->config->getLogging()->getReport('csv'), $this->output, new Details\Csv()))
84
            ->push(new ReportWriter($this->config->getLogging()->getViolation('xml'), $this->output, new Violations\Xml($validator, $bounds)))
85
            ->push(new ReportWriter($this->config->getLogging()->getChart('bubbles'), $this->output, new Chart\Bubbles($validator, $bounds)));
86
87
        return $queue;
88
    }
89
90
}
91