CheckPluginAbstract   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Test Coverage

Coverage 97.06%

Importance

Changes 0
Metric Value
wmc 11
eloc 65
dl 0
loc 113
ccs 66
cts 68
cp 0.9706
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A checkConf() 0 9 1
A _group() 0 12 1
A _descr() 0 8 1
A _importance() 0 20 3
A checkRequirements() 0 2 1
A checkFactoryConf() 0 16 1
A _tags() 0 8 1
A _label() 0 6 1
A _addition() 0 9 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\TreeBuilder;
16
use Tvi\MonitorBundle\Exception\FeatureRequired;
17
18
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
19
 * @author Vladimir Turnaev <[email protected]>
20
 */
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...
21
abstract class CheckPluginAbstract implements CheckPluginInterface
22
{
23
    /**
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...
24
     * @throws FeatureRequired
25
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
26 35
    public function checkRequirements(array $checkSettings)
27
    {
28 35
    }
29
30 57
    public function checkConf(TreeBuilder $builder): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function checkConf()
Loading history...
31
    {
32
        $node = $builder
33 57
            ->root(static::CHECK_NAME, 'array')
34 57
            ->info(static::DESCR); //--
35
36 57
        $this->_check($node);
37
38 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...
39
    }
40
41 57
    public function checkFactoryConf(TreeBuilder $builder): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function checkFactoryConf()
Loading history...
42
    {
43
        $node = $builder
44 57
            ->root(static::CHECK_NAME.'_factory', 'array')
45 57
            ->info(static::DESCR)
46 57
            ->children()
47 57
                ->arrayNode('items')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
48 57
                    ->prototype('array'); //--
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
49 57
        $node = $this->_check($node)
50 57
                    ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
51 57
                ->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

51
                ->/** @scrutinizer ignore-call */ end()
Loading history...
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
52 57
            ->end();
53
54 57
        $this->_addition($node);
55
56 57
        return $node;
57
    }
58
59 57
    protected function _addition(ArrayNodeDefinition $node): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function _addition()
Loading history...
Coding Style introduced by
Protected method name "CheckPluginAbstract::_addition" must not be prefixed with an underscore
Loading history...
60
    {
61 57
        $this->_group($node);
62 57
        $this->_tags($node);
63 57
        $this->_importance($node);
64 57
        $this->_label($node);
65 57
        $this->_descr($node);
66
67 57
        return $node;
68
    }
69
70
    abstract 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 "CheckPluginAbstract::_check" must not be prefixed with an underscore
Loading history...
71
72 57
    protected function _label(ArrayNodeDefinition $node): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function _label()
Loading history...
Coding Style introduced by
Protected method name "CheckPluginAbstract::_label" must not be prefixed with an underscore
Loading history...
73
    {
74
        return $node
75 57
            ->children()
76 57
                ->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...
77 57
            ->end();
78
    }
79
80 57
    protected function _importance(ArrayNodeDefinition $node): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function _importance()
Loading history...
Coding Style introduced by
Protected method name "CheckPluginAbstract::_importance" must not be prefixed with an underscore
Loading history...
81
    {
82
        return $node
83 57
            ->children()
84 57
                ->scalarNode('importance')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
85 57
                    ->validate()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
86 57
                        ->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...
87 1
                            if (null === $value) {
88
                                return false;
89 1
                            } elseif (\in_array($value, CheckAbstract::getImportances(), true)) {
90 1
                                return false;
91
                            }
92
93
                            return true;
94 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...
95 57
                        ->thenInvalid(sprintf('importance has to one of value [%s]', implode(', ', CheckAbstract::getImportances())))
96 57
                    ->end()
97 57
                    ->defaultNull()
98 57
                ->end()
99 57
            ->end();
100
    }
101
102 57
    protected function _group(ArrayNodeDefinition $node): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function _group()
Loading history...
Coding Style introduced by
Protected method name "CheckPluginAbstract::_group" must not be prefixed with an underscore
Loading history...
103
    {
104
        return $node
105 57
            ->children()
106 57
                ->scalarNode('group')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
107 57
                    ->cannotBeEmpty()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
108 57
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
109 57
                ->scalarNode('_group')
0 ignored issues
show
Bug introduced by
The method scalarNode() 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

109
                ->/** @scrutinizer ignore-call */ scalarNode('_group')
Loading history...
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
110 57
                    ->defaultValue(static::GROUP)
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
111 57
                    ->cannotBeOverwritten()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
112 57
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
113 57
            ->end();
114
    }
115
116 57
    protected function _tags(ArrayNodeDefinition $node): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function _tags()
Loading history...
Coding Style introduced by
Protected method name "CheckPluginAbstract::_tags" must not be prefixed with an underscore
Loading history...
117
    {
118
        return $node
119 57
            ->children()
120 57
                ->arrayNode('tags')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
121 57
                    ->prototype('scalar')->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
122 57
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
123 57
            ->end();
124
    }
125
126 57
    protected function _descr(ArrayNodeDefinition $node): ArrayNodeDefinition
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function _descr()
Loading history...
Coding Style introduced by
Protected method name "CheckPluginAbstract::_descr" must not be prefixed with an underscore
Loading history...
127
    {
128
        return $node
129 57
            ->children()
130 57
                ->scalarNode('descr')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
131 57
                    ->defaultNull()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
132 57
                ->end()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
133 57
            ->end();
134
    }
135
}
136