Passed
Push — master ( 965270...bfb1d4 )
by Vladimir
09:18 queued 02:13
created

Plugin::checkRequirements()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 2
cts 3
cp 0.6667
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.1481
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 Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
16
use Tvi\MonitorBundle\Check\CheckPluginAbstract;
17
use Tvi\MonitorBundle\Exception\FeatureRequired;
18
19
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
20
 * @author Vladimir Turnaev <[email protected]>
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 Plugin extends CheckPluginAbstract
23
{
24
    const DESCR =
0 ignored issues
show
Coding Style introduced by
Multi-line assignments must have the equal sign on the second line
Loading history...
25
<<<'TXT'
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
26
rabbit_mq description
27
TXT;
28
29
    const PATH = __DIR__;
30
31
    const GROUP = 'rabbit_mq';
32
    const CHECK_NAME = 'core:rabbit_mq:queue_consumer';
33
34
35
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $checkSettings should have a doc-comment as per coding-style.
Loading history...
36
     * @throws FeatureRequired
37
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
38 1
    public function checkRequirements(array $checkSettings)
39
    {
40 1
        if (!class_exists('PhpAmqpLib\Connection\AMQPConnection')) {
41
            throw new FeatureRequired('PhpAmqpLib is not installed');
42
        }
43 1
    }
44
45
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
46
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
47
     *
48
     * @return NodeDefinition|ArrayNodeDefinition
49
     */
50 56
    protected function _check(NodeDefinition $node): NodeDefinition
0 ignored issues
show
Coding Style introduced by
Protected method name "Plugin::_check" must not be prefixed with an underscore
Loading history...
51
    {
52
        $node = $node
53 56
            ->children()
54 56
                ->arrayNode('check')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
55 56
                    ->beforeNormalization()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
56 56
                        ->ifString()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 24
Loading history...
57
                        ->then(static function ($v) { return ['dsn' => $v]; })
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 24
Loading history...
Coding Style introduced by
Opening brace must be the last content on the line
Loading history...
Coding Style introduced by
Closing brace must be on a line by itself
Loading history...
58 56
                    ->end()
59 56
                    ->children()
60 56
                        ->scalarNode('host')->defaultValue('localhost')->end()
61 56
                        ->integerNode('port')->defaultValue(5672)->end()
62 56
                        ->scalarNode('user')->defaultValue('guest')->end()
63 56
                        ->scalarNode('password')->defaultValue('guest')->end()
64 56
                        ->scalarNode('vhost')->defaultValue('/')->end()
65 56
                        ->scalarNode('dsn')->defaultNull()->end()
66 56
                    ->end()
67 56
                ->end()
68 56
            ->end();
69
70 56
        $this->_addition($node);
71
72 56
        return $node;
73
    }
74
}
75