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

HasMoreThanOneProperty   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 61.53%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 40
ccs 8
cts 13
cp 0.6153
rs 10
c 1
b 0
f 0
wmc 4
lcom 0
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 9 2
A getConfiguration() 0 9 1
A getRegister() 0 6 1
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