Completed
Push — master ( 9bde22...42d1c1 )
by Vladimir
06:21
created

Nagius::onAfterRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
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
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
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\ResultInterface;
18
19
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
20
 * @author Kevin Bond <[email protected]>, Vladimir Turnaev <[email protected]>
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
21
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
22
class Nagius extends ReporterAbstract
23
{
24
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
25
     * @var OutputInterface
26
     */
27
    protected $output;
28
29
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
30
     * @param OutputInterface $output
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
31
     */
32 50
    public function __construct(OutputInterface $output = null)
33
    {
34 50
        if (null === $output) {
35 50
            $output = new ConsoleOutput();
36
        }
37 50
        $this->output = $output;
38 50
    }
39
40
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $check should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $result should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $checkAlias should have a doc-comment as per coding-style.
Loading history...
41
     * {@inheritdoc}
42
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
43
    public function onAfterRun(CheckInterface $check, ResultInterface $result, $checkAlias = null)
44
    {
45
        list($_, $code) = $this->getStatusByResul($result);
46
47
        $statusOut = $this->statusByCode($code);
48
        $this->output->writeln(sprintf("%-8s\t%-25s\t%s", $statusOut, $check->getId(), $check->getLabel()));
0 ignored issues
show
Bug introduced by
The method getId() does not exist on ZendDiagnostics\Check\CheckInterface. It seems like you code against a sub-type of ZendDiagnostics\Check\CheckInterface such as Tvi\MonitorBundle\Check\CheckInterface or Tvi\MonitorBundle\Check\fs\DiskUsage\Check or Tvi\MonitorBundle\Check\php\PhpFlag\Check or Tvi\MonitorBundle\Check\fs\DirWritable\Check or Tvi\MonitorBundle\Check\php\ApcMemory\Check or Tvi\MonitorBundle\Check\php\OpCacheMemory\Check or Tvi\MonitorBundle\Check\php\ClassExists\Check or Tvi\MonitorBundle\Check\sys\CpuPerformance\Check or Tvi\MonitorBundle\Check\db\PDOCheck\Check or Tvi\MonitorBundle\Check\fs\DirReadable\Check or Tvi\MonitorBundle\Check\fs\DiskFree\Check or Tvi\MonitorBundle\Check\...xtensionNotLoaded\Check or Tvi\MonitorBundle\Check\php\ExtensionLoaded\Check or Tvi\MonitorBundle\Check\php\ApcFragmentation\Check or Tvi\MonitorBundle\Check\php\PhpVersion\Check or Tvi\MonitorBundle\Check\...reamWrapperExists\Check or Tvi\MonitorBundle\Test\C...\TestSuccessCheck\Check or Tvi\MonitorBundle\Check\php\Expression\Check or Tvi\MonitorBundle\Test\C...\TestWarningCheck\Check or Tvi\MonitorBundle\Test\Check\TestSkipCheck\Check or Tvi\MonitorBundle\Test\C...\TestFailureCheck\Check or Tvi\MonitorBundle\Check\fs\IniFile\Check or Tvi\MonitorBundle\Check\fs\XmlFile\Check or Tvi\MonitorBundle\Check\fs\YamlFile\Check or Tvi\MonitorBundle\Check\fs\JsonFile\Check or Tvi\MonitorBundle\Check\fs\DiskUsage\Check or Tvi\MonitorBundle\Check\php\PhpFlag\Check or Tvi\MonitorBundle\Check\fs\DirWritable\Check or Tvi\MonitorBundle\Check\php\ApcMemory\Check or Tvi\MonitorBundle\Check\php\OpCacheMemory\Check or Tvi\MonitorBundle\Check\php\ClassExists\Check or Tvi\MonitorBundle\Check\redis\Redis\Check or Tvi\MonitorBundle\Check\php\SecurityAdvisory\Check or Tvi\MonitorBundle\Check\sys\CpuPerformance\Check or Tvi\MonitorBundle\Check\sys\ProcessRunning\Check or Tvi\MonitorBundle\Check\fs\DirReadable\Check or Tvi\MonitorBundle\Check\mongo\Mongo\Check or Tvi\MonitorBundle\Check\fs\DiskFree\Check or Tvi\MonitorBundle\Check\memcache\Memcached\Check or Tvi\MonitorBundle\Check\...xtensionNotLoaded\Check or Tvi\MonitorBundle\Check\php\ExtensionLoaded\Check or Tvi\MonitorBundle\Check\php\ApcFragmentation\Check or Tvi\MonitorBundle\Check\php\PhpVersion\Check or Tvi\MonitorBundle\Check\memcache\Memcache\Check or Tvi\MonitorBundle\Check\http\HttpService\Check or Tvi\MonitorBundle\Check\...GuzzleHttpService\Check or Tvi\MonitorBundle\Check\...reamWrapperExists\Check or Tvi\MonitorBundle\Check\rabbitmq\RabbitMQ\Check. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
        $this->output->writeln(sprintf("%-8s\t%-25s\t%s", $statusOut, $check->/** @scrutinizer ignore-call */ getId(), $check->getLabel()));
Loading history...
49
    }
50
51
    protected function statusByCode($code): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function statusByCode()
Loading history...
52
    {
53
        $tags = [
54
            self::STATUS_CODE_SUCCESS => 'OK',
55
            self::STATUS_CODE_WARNING => 'WARNING',
56
            self::STATUS_CODE_SKIP => 'SKIP',
57
            self::STATUS_CODE_FAILURE => 'FAIL',
58
            'default' => 'FAIL',
59
        ];
60
61
        return $tags[$code] ?? $tags['default'];
62
    }
63
}
64