ReportRenderer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4286
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
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\FormaterInterface;
12
use Hal\Component\Result\ResultCollection;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
16
/**
17
 * Job report renderer
18
 *
19
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
20
 */
21
class ReportRenderer implements JobInterface
22
{
23
24
    /**
25
     * Formater
26
     *
27
     * @var FormaterInterface
28
     */
29
    private $formater;
30
31
    /**
32
     * Output
33
     *
34
     * @var \Symfony\Component\Console\Output\OutputInterface
35
     */
36
    private $output;
37
38
    /**
39
     * Is enabled ?
40
     *
41
     * @var bool
42
     */
43
    private $enabled = false;
44
45
    /**
46
     * Constructor
47
     *
48
     * @param boolean $enabled
49
     * @param OutputInterface $output
50
     * @param FormaterInterface $formater
51
     */
52
    function __construct($enabled, OutputInterface $output, FormaterInterface $formater)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
53
    {
54
        $this->output = $output;
55
        $this->enabled = $enabled;
56
        $this->formater = $formater;
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62
    public function execute(ResultCollection $collection, ResultCollection $aggregatedResults) {
63
        if(!$this->enabled) {
64
            return;
65
        }
66
67
        $this->output->write($this->formater->terminate($collection, $aggregatedResults));
68
    }
69
70
}
71