InlineIf   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 14
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 8 2
1
<?php
2
3
namespace MS\PHPMD\Rule\CleanCode;
4
5
use PHPMD\AbstractNode;
6
use PHPMD\AbstractRule;
7
use PHPMD\Node\MethodNode;
8
use PHPMD\Rule\MethodAware;
9
10
/**
11
 * Class InlineIf
12
 *
13
 * Try to avoid using inline ifs. They conceal the complexity of your code.
14
 * Furthermore they obstruct the expandability. Refactor your code and increase the readability.
15
 *
16
 * @package MS\PHPMD\Rule\CleanCode
17
 */
18
class InlineIf extends AbstractRule implements MethodAware
19
{
20
    /**
21
     * @param AbstractNode|MethodNode $node
22
     */
23 2
    public function apply(AbstractNode $node)
24
    {
25 2
        $conditionalExpressions = $node->findChildrenOfType('ConditionalExpression');
26
27 2
        foreach ($conditionalExpressions as $conditionalExpression) {
28 1
            $this->addViolation($conditionalExpression);
29 2
        }
30 2
    }
31
}
32