Passed
Push — master ( 624c72...422b2f )
by Vladimir
06:35
created

Plugin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 95.83%

Importance

Changes 0
Metric Value
wmc 4
eloc 29
dl 0
loc 51
ccs 23
cts 24
cp 0.9583
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkRequirements() 0 4 2
A _check() 0 24 2
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\php\Expression;
13
14
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
15
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
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
    public 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
expression description
27
TXT;
28
29
    public const PATH = __DIR__;
30
31
    public const GROUP = 'php';
32
    public const CHECK_NAME = 'core:expression';
33
34
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
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()
38
    {
39 1
        if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
40
            throw new FeatureRequired('The symfony/expression-language is required for '.static::class.' check.');
41
        }
42 1
    }
43
44
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
45
     * @param NodeDefinition|ArrayNodeDefinition $node
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
46
     *
47
     * @return NodeDefinition|ArrayNodeDefinition
48
     */
49 49
    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...
50
    {
51
        $node = $node
52 49
            ->children()
53 49
                ->arrayNode('check')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 16
Loading history...
54 49
                    ->addDefaultsIfNotSet()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
55 49
                    ->validate()
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
56 49
                        ->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...
57 1
                            return !$value['warningExpression'] && !$value['criticalExpression'];
58 49
                        })
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...
59 49
                        ->thenInvalid('A warningExpression or a criticalExpression must be set.')
60 49
                    ->end()
61 49
                    ->children()
62 49
                      ->scalarNode('criticalExpression')->defaultNull()->example('ini(\'apc.stat\') == 0')->end()
63 49
                      ->scalarNode('criticalMessage')->defaultNull()->end()
64 49
                      ->scalarNode('warningExpression')->defaultNull()->example('ini(\'short_open_tag\') == 1')->end()
65 49
                      ->scalarNode('warningMessage')->defaultNull()->end()
66 49
                    ->end()
67 49
                ->end()
68 49
            ->end();
69
70 49
        $this->_addition($node);
71
72 49
        return $node;
73
    }
74
}
75