forked from liip/LiipMonitorBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleReporter.php
More file actions
96 lines (80 loc) · 2.3 KB
/
ConsoleReporter.php
File metadata and controls
96 lines (80 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace Liip\MonitorBundle\Helper;
use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Collection as ResultsCollection;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\SkipInterface;
use Laminas\Diagnostics\Result\SuccessInterface;
use Laminas\Diagnostics\Result\WarningInterface;
use Laminas\Diagnostics\Runner\Reporter\ReporterInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @author Kevin Bond <kevinbond@gmail.com>
*/
class ConsoleReporter implements ReporterInterface
{
/**
* @var OutputInterface
*/
protected $output;
public function __construct(?OutputInterface $output = null)
{
if (null === $output) {
$output = new ConsoleOutput();
}
$this->output = $output;
}
public function setOutput(OutputInterface $output): void
{
$this->output = $output;
}
/**
* @return bool|void
*/
public function onAfterRun(CheckInterface $check, ResultInterface $result, $checkAlias = null)
{
switch (true) {
case $result instanceof SuccessInterface:
$this->output->write('<info>OK</info>');
break;
case $result instanceof WarningInterface:
$this->output->write('<comment>WARNING</comment>');
break;
case $result instanceof SkipInterface:
$this->output->write('<question>SKIP</question>');
break;
default:
$this->output->write('<error>FAIL</error>');
}
$this->output->write(sprintf(' %s', $check->getLabel()));
if ($message = $result->getMessage()) {
$this->output->write(sprintf(': %s', $message));
}
$this->output->writeln('');
}
/**
* @return void
*/
public function onStart(\ArrayObject $checks, $runnerConfig)
{
}
/**
* @return bool|void
*/
public function onBeforeRun(CheckInterface $check, $checkAlias = null)
{
}
/**
* @return void
*/
public function onStop(ResultsCollection $results)
{
}
/**
* @return void
*/
public function onFinish(ResultsCollection $results)
{
}
}