Completed
Pull Request — master (#243)
by
unknown
03:31
created

ForCondition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 13 2
A getRegister() 0 6 1
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 1
    public function pass(For_ $stmt, Context $context)
15
    {
16 1
        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 1
        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