Completed
Push — master ( 3e0393...c84f1e )
by Enrico
09:13
created

ForCondition::pass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PHPSA\Analyzer\Pass\Statement;
4
5
use PhpParser\Node\Stmt\For_;
6
use PHPSA\Analyzer\Helper\DefaultMetadataPassTrait;
7
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
8
use PHPSA\Context;
9
10
class ForCondition implements AnalyzerPassInterface
11
{
12
    use DefaultMetadataPassTrait;
13
14 7
    public function pass(For_ $stmt, Context $context)
15
    {
16 7
        if (count($stmt->cond) > 1) {
17 1
            $context->notice(
18 1
                'for_condition',
19 1
                'You should merge the conditions into one with &&',
20
                $stmt
21 1
            );
22 1
            return false;
23
        }
24
25 7
        return true;
26
    }
27
28
    /**
29
     * @return array
30
     */
31 1
    public function getRegister()
32
    {
33
        return [
34 1
            For_::class,
35 1
        ];
36
    }
37
}
38