|
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) |
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
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))); |
|
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
return $queue; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
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.