Completed
Pull Request — master (#177)
by
unknown
04:21 queued 01:12
created

HasMoreThanOneProperty::getConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
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
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
11
12
class HasMoreThanOneProperty implements Pass\ConfigurablePassInterface, Pass\AnalyzerPassInterface
13
{
14
    /**
15
     * @param Property $prop
16
     * @param Context $context
17
     * @return bool
18
     */
19 4
    public function pass(Property $prop, Context $context)
20
    {
21 4
        if (count($prop->props) > 1) {
22 2
            $context->notice('limit.properties', 'Number of properties larger than one.', $prop);
23 2
            return true;
24
        }
25
26 4
        return false;
27
    }
28
29
    /**
30
     * @return TreeBuilder
31
     */
32
    public function getConfiguration()
33
    {
34
        $treeBuilder = new TreeBuilder();
35
        $treeBuilder->root('limit.properties')
36
            ->canBeDisabled()
37
        ;
38
39
        return $treeBuilder;
40
    }
41
42
    /**
43
     * @return array
44
     */
45 1
    public function getRegister()
46
    {
47
        return [
48 1
            Property::class,
49 1
        ];
50
    }
51
}
52