Completed
Push — master ( 3708b9...fb0aff )
by Enrico
03:36
created

HasMoreThanOneProperty::pass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 9.6666
c 1
b 0
f 0
1
<?php
2
/**
3
 * @author Leonardo da Mata https://github.com/barroca <[email protected]>
4
 */
5
namespace PHPSA\Analyzer\Pass\Statement;
6
7
use PhpParser\Node\Stmt\Property;
8
use PHPSA\Analyzer\Pass;
9
use PHPSA\Context;
10
11
class HasMoreThanOneProperty implements Pass\AnalyzerPassInterface
12
{
13
    /**
14
     * @param Property $prop
15
     * @param Context $context
16
     * @return bool
17
     */
18 6
    public function pass(Property $prop, Context $context)
19
    {
20 6
        if (count($prop->props) > 1) {
21 2
            $context->notice('limit.properties', 'Number of properties larger than one.', $prop);
22 2
            return true;
23
        }
24
25 6
        return false;
26
    }
27
28
    /**
29
     * @return array
30
     */
31 1
    public function getRegister()
32
    {
33
        return [
34 1
            Property::class,
35 1
        ];
36
    }
37
}
38