Completed
Pull Request — master (#202)
by personal
03:02
created

QueueAnalyzeFactory::factory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 2
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\Formater\Chart;
13
use Hal\Application\Formater\Details;
14
use Hal\Application\Formater\Summary;
15
use Hal\Application\Formater\Violations;
16
use Hal\Application\Score\Scoring;
17
use Hal\Component\Aggregator\DirectoryAggregatorFlat;
18
use Hal\Component\Bounds\BoundsInterface;
19
use Hal\Component\Config\ConfigurationInterface;
20
use Hal\Component\File\Finder;
21
use Symfony\Component\Console\Input\InputInterface;
22
use Symfony\Component\Console\Output\OutputInterface;
23
24
/**
25
 * Queue factory
26
 *
27
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
28
 */
29
class QueueAnalyzeFactory
30
{
31
32
    /**
33
     * @var ConfigurationInterface
34
     */
35
    private $config;
36
37
    /**
38
     * @var OutputInterface
39
     */
40
    private $output;
41
42
    /**
43
     * @var InputInterface
44
     */
45
    private $input;
46
47
    /**
48
     * @var ExtensionService
49
     */
50
    private $extensionsService;
51
52
    /**
53
     * Constructor
54
     *
55
     * @param InputInterface $input
56
     * @param OutputInterface $output
57
     * @param ConfigurationInterface $config
58
     * @param ExtensionService $extensionService
59
     */
60 View Code Duplication
    public function __construct(InputInterface $input, OutputInterface $output, ConfigurationInterface $config, ExtensionService $extensionService)
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...
61
    {
62
        $this->config = $config;
63
        $this->input = $input;
64
        $this->output = $output;
65
        $this->extensionsService = $extensionService;
66
    }
67
68
    /**
69
     * Factory queue
70
     *
71
     * @param Finder $finder
72
     * @param BoundsInterface $bounds
73
     * @return Queue
74
     */
75
    public function factory(Finder $finder, BoundsInterface $bounds) {
76
        $rules = $this->config->getRuleSet();
77
        $validator = new \Hal\Application\Rule\Validator($rules);
0 ignored issues
show
Unused Code introduced by
$validator is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
78
79
        // jobs queue planning
80
        $queue = new Queue;
81
        $queue
82
            ->push(new DoAnalyze($this->output, $finder, $this->config->getPath()->getBasePath(), !$this->input->getOption('without-oop'), $this->config->getIgnoreErrors()))
83
            ->push(new SearchBounds($this->output, $bounds))
84
            ->push(new DoAggregatedAnalyze($this->output, new DirectoryAggregatorFlat($this->input->getOption('level'))))
85
            ->push(new CalculateScore(new Scoring($bounds)))
86
        ;
87
88
        return $queue;
89
    }
90
91
}
92