Completed
Pull Request — master (#243)
by
unknown
12:06 queued 06:15
created

ForCondition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

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
13
    use DefaultMetadataPassTrait;
14
15 8
    public function pass(For_ $stmt, Context $context)
16
    {
17 8
        if (count($stmt->cond) > 1) {
18 1
            $context->notice(
19 1
                'for_condition',
20 1
                'You should merge the conditions into one with &&',
21
                $stmt
22 1
            );
23 1
            return false;
24
        }
25
26 8
        return true;
27
    }
28
29
    /**
30
     * @return array
31
     */
32 1
    public function getRegister()
33
    {
34
        return [
35 1
            For_::class,
36 1
        ];
37
    }
38
}
39