Passed
Push — master ( 505a98...965270 )
by Vladimir
07:00
created

Check::check()   A

Complexity

Conditions 2
Paths 6

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.5

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 12
ccs 4
cts 8
cp 0.5
rs 10
c 0
b 0
f 0
cc 2
nc 6
nop 0
crap 2.5
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\Check\rabbitmq\QueueConsumer;
13
14
use JMS\Serializer\Annotation as JMS;
15
use Tvi\MonitorBundle\Check\rabbitmq\RabbitMQClient;
16
use Tvi\MonitorBundle\Check\CheckAbstract;
17
use ZendDiagnostics\Result\Failure;
18
use ZendDiagnostics\Result\Success;
19
20
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
 * @JMS\ExclusionPolicy("all")
22
 *
23
 * @author Vladimir Turnaev <[email protected]>
24
 */
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...
25
class Check extends CheckAbstract
26
{
27
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
28
     * @var RabbitMQClient
29
     */
30
    private $client;
0 ignored issues
show
Coding Style introduced by
Private member variable "client" must be prefixed with an underscore
Loading history...
31
32
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
33
     * @param string     $host
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
34
     * @param int        $port
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
35
     * @param string     $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
36
     * @param string     $password
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
37
     * @param string     $vhost
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
38
     * @param null|mixed $dsn
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
39
     */
40 2
    public function __construct(
41
        $host = 'localhost',
42
        $port = 5672,
43
        $user = 'guest',
44
        $password = 'guest',
45
        $vhost = '/',
46
        $dsn = null)
0 ignored issues
show
Coding Style introduced by
The closing parenthesis of a multi-line function declaration must be on a new line
Loading history...
47
    {
0 ignored issues
show
Coding Style introduced by
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
48 2
        $this->client = new RabbitMQClient($host,
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
49 2
            $port,
50 2
            $user,
51 2
            $password,
52 2
            $vhost,
53 2
            $dsn);
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 8 spaces, but found 12.
Loading history...
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
54 2
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
59 2
    public function check()
60
    {
61
        try {
62 2
            $conn = $this->client->getConnect();
63
            $conn->channel();
64
65
            $conn->isConnected();
66
            $version = $conn->getServerProperties()['version'][1];
67
68
            return new Success(null, $version);
69 2
        } catch (\Exception $e) {
70 2
            return new Failure($e->getMessage());
71
        }
72
    }
73
}
74