Completed
Push — master ( 0c920d...85aa21 )
by Kevin
06:03
created

RawConsoleReporter::setOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Liip\MonitorBundle\Helper;
4
5
use Laminas\Diagnostics\Check\CheckInterface;
6
use Laminas\Diagnostics\Result\Collection as ResultsCollection;
7
use Laminas\Diagnostics\Result\ResultInterface;
8
use Laminas\Diagnostics\Result\SkipInterface;
9
use Laminas\Diagnostics\Result\SuccessInterface;
10
use Laminas\Diagnostics\Result\WarningInterface;
11
use Laminas\Diagnostics\Runner\Reporter\ReporterInterface;
12
use Symfony\Component\Console\Output\ConsoleOutput;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
/**
16
 * Like ConsoleReporter, but without coloration, and no message.
17
 */
18
class RawConsoleReporter implements ReporterInterface
19
{
20
    /**
21
     * @var OutputInterface
22
     */
23
    protected $output;
24
25
    /**
26
     * @param OutputInterface $output
27
     */
28 View Code Duplication
    public function __construct(OutputInterface $output = null)
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...
29
    {
30
        if (null === $output) {
31
            $output = new ConsoleOutput();
32
        }
33
        $this->output = $output;
34
    }
35
36
    public function setOutput(OutputInterface $output)
37
    {
38
        $this->output = $output;
39
    }
40
41
    public function onAfterRun(CheckInterface $check, ResultInterface $result, $checkAlias = null)
42
    {
43 View Code Duplication
        switch (true) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
44
            case $result instanceof SuccessInterface:
45
                $this->output->write('OK');
46
                break;
47
48
            case $result instanceof WarningInterface:
49
                $this->output->write('WARNING');
50
                break;
51
52
            case $result instanceof SkipInterface:
53
                $this->output->write('SKIP');
54
                break;
55
56
            default:
57
                $this->output->write('FAIL');
58
        }
59
60
        $performanceData = $this->getNagiosPerformanceData();
61
62
        $this->output->writeln(sprintf(' %s', $check->getLabel().$performanceData));
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    protected function getNagiosPerformanceData()
69
    {
70
        return '';
71
    }
72
73
    public function onStart(\ArrayObject $checks, $runnerConfig)
74
    {
75
        return;
76
    }
77
78
    public function onBeforeRun(CheckInterface $check, $checkAlias = null)
79
    {
80
        return;
81
    }
82
83
    public function onStop(ResultsCollection $results)
84
    {
85
        return;
86
    }
87
88
    public function onFinish(ResultsCollection $results)
89
    {
90
        return;
91
    }
92
}
93