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

QueueAnalyzeFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 11.11 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A factory() 0 15 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\Formater\Chart;
13
use Hal\Application\Formater\Details;
14
use Hal\Application\Formater\Summary;
15
use Hal\Application\Formater\Violations;
16
use Hal\Application\Rule\Validator;
17
use Hal\Application\Score\Scoring;
18
use Hal\Component\Aggregator\DirectoryAggregatorFlat;
19
use Hal\Component\Bounds\BoundsInterface;
20
use Hal\Component\Config\ConfigurationInterface;
21
use Hal\Component\File\Finder;
22
use Symfony\Component\Console\Input\InputInterface;
23
use Symfony\Component\Console\Output\OutputInterface;
24
25
/**
26
 * Queue factory
27
 *
28
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
29
 */
30
class QueueAnalyzeFactory
31
{
32
33
    /**
34
     * @var ConfigurationInterface
35
     */
36
    private $config;
37
38
    /**
39
     * @var OutputInterface
40
     */
41
    private $output;
42
43
    /**
44
     * @var InputInterface
45
     */
46
    private $input;
47
48
    /**
49
     * @var ExtensionService
50
     */
51
    private $extensionsService;
52
53
    /**
54
     * Constructor
55
     *
56
     * @param InputInterface $input
57
     * @param OutputInterface $output
58
     * @param ConfigurationInterface $config
59
     * @param ExtensionService $extensionService
60
     */
61 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...
62
    {
63
        $this->config = $config;
64
        $this->input = $input;
65
        $this->output = $output;
66
        $this->extensionsService = $extensionService;
67
    }
68
69
    /**
70
     * Factory queue
71
     *
72
     * @param Finder $finder
73
     * @param BoundsInterface $bounds
74
     * @return Queue
75
     */
76
    public function factory(Finder $finder, BoundsInterface $bounds) {
77
        $rules = $this->config->getRuleSet();
78
        $validator = new 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...
79
80
        // jobs queue planning
81
        $queue = new Queue;
82
        $queue
83
            ->push(new DoAnalyze($this->output, $finder, $this->config->getPath()->getBasePath(), !$this->input->getOption('without-oop'), $this->config->getIgnoreErrors()))
84
            ->push(new SearchBounds($this->output, $bounds))
85
            ->push(new DoAggregatedAnalyze($this->output, new DirectoryAggregatorFlat($this->input->getOption('level'))))
86
            ->push(new CalculateScore(new Scoring($bounds)))
87
        ;
88
89
        return $queue;
90
    }
91
92
}
93