Completed
Push — master ( 13c004...92d87a )
by Vladimir
06:13
created

CheckPluginAbstract::getImportances()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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;
13
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
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
abstract class CheckPluginAbstract implements CheckPluginInterface
23
{
24
    /**
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...
25
     * @throws FeatureRequired
26
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
27 37
    public function checkRequirements(array $checkSettings)
28
    {
29 37
    }
30
31
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $builder should have a doc-comment as per coding-style.
Loading history...
32
     * @return NodeDefinition|ArrayNodeDefinition
33
     */
34 54
    public function checkConf(TreeBuilder $builder): NodeDefinition
35
    {
36
        $node = $builder
37 54
            ->root(static::CHECK_NAME, 'array')
38 54
            ->info(static::DESCR); //--
39
40 54
        $this->_check($node);
41
42 54
        return $node;
43
    }
44
45
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $builder should have a doc-comment as per coding-style.
Loading history...
46
     * @return NodeDefinition|ArrayNodeDefinition
47
     */
48 54
    public function checkFactoryConf(TreeBuilder $builder): NodeDefinition
49
    {
50
        $node = $builder
51 54
            ->root(static::CHECK_NAME.'_factory', 'array')
52 54
            ->info(static::DESCR)
53 54
            ->children()
54 54
                ->arrayNode('items')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
55 54
                    ->prototype('array'); //--
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
56 54
        $node = $this->_check($node)
57 54
                    ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
58 54
                ->end()
0 ignored issues
show
Bug introduced by
The method end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those? ( Ignorable by Annotation )

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

58
                ->/** @scrutinizer ignore-call */ end()
Loading history...
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
59 54
            ->end();
60
61 54
        $this->_addition($node);
62
63 54
        return $node;
64
    }
65
66
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
67
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
68
     *
69
     * @return NodeDefinition|ArrayNodeDefinition
70
     */
71 54
    protected function _addition(NodeDefinition $node): NodeDefinition
0 ignored issues
show
Coding Style introduced by
Protected method name "CheckPluginAbstract::_addition" must not be prefixed with an underscore
Loading history...
72
    {
73 54
        $this->_group($node);
74 54
        $this->_tags($node);
75 54
        $this->_importance($node);
76 54
        $this->_label($node);
77 54
        $this->_descr($node);
78
79
80 54
        return $node;
81
    }
82
83
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
84
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
85
     *
86
     * @return NodeDefinition|ArrayNodeDefinition
87
     */
88
    abstract protected function _check(NodeDefinition $node): NodeDefinition;
0 ignored issues
show
Coding Style introduced by
Protected method name "CheckPluginAbstract::_check" must not be prefixed with an underscore
Loading history...
89
90
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
91
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
92
     *
93
     * @return NodeDefinition|ArrayNodeDefinition
94
     */
95 54
    protected function _label(NodeDefinition $node): NodeDefinition
0 ignored issues
show
Coding Style introduced by
Protected method name "CheckPluginAbstract::_label" must not be prefixed with an underscore
Loading history...
96
    {
97
        return $node
98 54
            ->children()
99 54
                ->scalarNode('label')->defaultNull()->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
100 54
            ->end();
101
    }
102
103
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
104
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
105
     *
106
     * @return NodeDefinition|ArrayNodeDefinition
107
     */
108 54
    protected function _importance(ArrayNodeDefinition $node): NodeDefinition
0 ignored issues
show
Coding Style introduced by
Protected method name "CheckPluginAbstract::_importance" must not be prefixed with an underscore
Loading history...
109
    {
110
        return $node
111 54
            ->children()
112 54
                ->scalarNode('importance')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
113 54
                    ->validate()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
114 54
                        ->ifTrue(static function ($value) {
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
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
115 1
                            if (null === $value) {
116
                                return false;
117 1
                            } else if (\in_array($value, CheckAbstract::getImportances(), true)) {
118 1
                                return false;
119
                            }
120
                            return true;
121 54
                        })
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...
122 54
                        ->thenInvalid(sprintf('importance has to one of value [%s]', implode(', ', CheckAbstract::getImportances())))
123 54
                    ->end()
124 54
                    ->defaultNull()
125 54
                ->end()
126 54
            ->end();
127
    }
128
129
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
130
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
131
     *
132
     * @return NodeDefinition|ArrayNodeDefinition
133
     */
134 54
    protected function _group(NodeDefinition $node): NodeDefinition
0 ignored issues
show
Coding Style introduced by
Protected method name "CheckPluginAbstract::_group" must not be prefixed with an underscore
Loading history...
135
    {
136
        return $node
137 54
            ->children()
138 54
                ->scalarNode('group')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
139 54
                    ->cannotBeEmpty()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
140 54
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
141 54
                ->scalarNode('_group')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
142 54
                    ->defaultValue(static::GROUP)
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
143 54
                    ->cannotBeOverwritten()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
144 54
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
145 54
            ->end();
146
    }
147
148
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
149
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
150
     *
151
     * @return NodeDefinition|ArrayNodeDefinition
152
     */
153 54
    protected function _tags(NodeDefinition $node): NodeDefinition
0 ignored issues
show
Coding Style introduced by
Protected method name "CheckPluginAbstract::_tags" must not be prefixed with an underscore
Loading history...
154
    {
155
        return $node
156 54
            ->children()
157 54
                ->arrayNode('tags')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
158 54
                    ->prototype('scalar')->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
159 54
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
160 54
            ->end();
161
    }
162
163
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
164
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
165
     *
166
     * @return NodeDefinition|ArrayNodeDefinition
167
     */
168 54
    protected function _descr(NodeDefinition $node): NodeDefinition
0 ignored issues
show
Coding Style introduced by
Protected method name "CheckPluginAbstract::_descr" must not be prefixed with an underscore
Loading history...
169
    {
170
        return $node
171 54
            ->children()
172 54
                ->scalarNode('descr')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
173 54
                    ->defaultNull()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
174 54
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
175 54
            ->end();
176
    }
177
}
178