Passed
Push — master ( 2ac8f3...446e83 )
by Vladimir
06:17
created

Plugin::_check()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 18
ccs 14
cts 14
cp 1
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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\etcd\Etcd;
13
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
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 = 'etcd';
32
    const CHECK_NAME = 'core:etcd';
33
34
    /**
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...
35
     * @throws FeatureRequired
36
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
37 1
    public function checkRequirements(array $checkSettings)
38
    {
39 1
        if (!interface_exists('\GuzzleHttp\ClientInterface')) {
40
            throw new FeatureRequired('GuzzleHttp is not installed');
41
        }
42 1
    }
43
44 57
    public function checkFactoryConf(TreeBuilder $builder): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function checkFactoryConf()
Loading history...
45
    {
46
        /* @var ArrayNodeDefinition $node */
47 57
        $node = parent::checkFactoryConf($builder);
48
49
        $keys = [
50 57
            'url',
51
            'verify',
52
            'cert',
53
            'sslKey',
54
            'ca'
55
        ];
56
        $node = $node
57 57
            ->beforeNormalization()
58 57
            ->ifArray()
59 57
            ->then(static function ($value) use ($keys) {
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...
60 1
                foreach ($keys as $key) {
61 1
                    if (isset($value[$key])) {
62
                        foreach ($value['items'] as &$v) {
63
                            if (!array_key_exists($key, $v['check'])) {
64 1
                                $v['check'][$key] = $value[$key];
65
                            }
66
                        }
67
                    }
68
                }
69
70 1
                return $value;
71 57
            })
0 ignored issues
show
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...
72 57
            ->end();
73
74 57
        $node->children()
75 57
            ->scalarNode('url')->end()
76 57
            ->booleanNode('verify')->end()
77 57
            ->scalarNode('cert')->end()
78 57
            ->scalarNode('sslKey')->end()
79 57
            ->scalarNode('ca')->end()
80 57
        ->end();
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 8
Loading history...
81
82 57
        return $node;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $node returns the type Symfony\Component\Config...\Builder\NodeDefinition which includes types incompatible with the type-hinted return Symfony\Component\Config...der\ArrayNodeDefinition.
Loading history...
83
    }
84
85 57
    protected function _check(ArrayNodeDefinition $node): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function _check()
Loading history...
Coding Style introduced by
Protected method name "Plugin::_check" must not be prefixed with an underscore
Loading history...
86
    {
87
        $node = $node
88 57
            ->children()
89 57
                ->arrayNode('check')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
90 57
                    ->children()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
91 57
                        ->scalarNode('url')->defaultValue('https://localhost:2379')->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 24
Loading history...
92 57
                        ->booleanNode('verify')->defaultValue(false)->end()
0 ignored issues
show
Bug introduced by
The method booleanNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

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

92
                        ->/** @scrutinizer ignore-call */ booleanNode('verify')->defaultValue(false)->end()
Loading history...
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 24
Loading history...
93 57
                        ->scalarNode('cert')->defaultValue('/etc/etcd/cert/client-etcd.crt')->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 24
Loading history...
94 57
                        ->scalarNode('sslKey')->defaultValue('/etc/etcd/cert/client-etcd.key')->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 24
Loading history...
95 57
                        ->scalarNode('ca')->defaultValue('/etc/etcd/cert/ca.crt')->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 24
Loading history...
96 57
                    ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
97 57
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
98 57
            ->end();
99
100 57
        $this->_addition($node);
101
102 57
        return $node;
103
    }
104
}
105