1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the `tvi/monitor-bundle` project. |
5
|
|
|
* |
6
|
|
|
* (c) https://github.com/turnaev/monitor-bundle/graphs/contributors |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Tvi\MonitorBundle\Reporter; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
use ZendDiagnostics\Check\CheckInterface; |
17
|
|
|
use ZendDiagnostics\Result\Collection as ResultsCollection; |
18
|
|
|
use ZendDiagnostics\Result\ResultInterface; |
19
|
|
|
use ZendDiagnostics\Result\SkipInterface; |
20
|
|
|
use ZendDiagnostics\Result\SuccessInterface; |
21
|
|
|
use ZendDiagnostics\Result\WarningInterface; |
22
|
|
|
|
23
|
|
|
/** |
|
|
|
|
24
|
|
|
* @author Kevin Bond <[email protected]>, Vladimir Turnaev <[email protected]> |
|
|
|
|
25
|
|
|
*/ |
|
|
|
|
26
|
|
|
class RawConsoleReporter extends AbstractReporter |
27
|
|
|
{ |
28
|
|
|
/** |
|
|
|
|
29
|
|
|
* @var OutputInterface |
30
|
|
|
*/ |
31
|
|
|
protected $output; |
32
|
|
|
|
33
|
|
|
/** |
|
|
|
|
34
|
|
|
* @param OutputInterface $output |
|
|
|
|
35
|
|
|
*/ |
36
|
|
|
public function __construct(OutputInterface $output = null) |
37
|
|
|
{ |
38
|
|
|
if (null === $output) { |
39
|
|
|
$output = new ConsoleOutput(); |
40
|
|
|
} |
41
|
|
|
$this->output = $output; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
|
|
|
|
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
|
|
|
|
47
|
|
|
public function onAfterRun(CheckInterface $check, ResultInterface $result, $checkAlias = null) |
48
|
|
|
{ |
49
|
|
|
switch (true) { |
50
|
|
|
case $result instanceof SuccessInterface: |
|
|
|
|
51
|
|
|
$statusOut = 'OK'; |
52
|
|
|
break; |
53
|
|
|
|
54
|
|
|
case $result instanceof WarningInterface: |
|
|
|
|
55
|
|
|
$statusOut = 'WARNING'; |
56
|
|
|
break; |
57
|
|
|
|
58
|
|
|
case $result instanceof SkipInterface: |
|
|
|
|
59
|
|
|
$statusOut = 'SKIP'; |
60
|
|
|
break; |
61
|
|
|
|
62
|
|
|
default: |
|
|
|
|
63
|
|
|
$statusOut = 'FAIL'; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$this->output->writeln(sprintf('%-8s %-25s %s', $statusOut, $check->getId(), $check->getLabel())); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
|
|
|
|
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
|
|
|
|
72
|
|
|
public function onStart(\ArrayObject $checks, $runnerConfig) |
73
|
|
|
{ |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
|
|
|
|
77
|
|
|
* {@inheritdoc} |
78
|
|
|
*/ |
|
|
|
|
79
|
|
|
public function onBeforeRun(CheckInterface $check, $checkAlias = null) |
80
|
|
|
{ |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
|
|
|
|
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
|
|
|
|
86
|
|
|
public function onStop(ResultsCollection $results) |
87
|
|
|
{ |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
|
|
|
|
91
|
|
|
* {@inheritdoc} |
92
|
|
|
*/ |
|
|
|
|
93
|
|
|
public function onFinish(ResultsCollection $results) |
94
|
|
|
{ |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|