Passed
Push — master ( d3a94c...76e109 )
by Valentin
05:50
created

LocateProperties   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A leaveNode() 0 16 5
A getProperties() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Cycle\ORM\Promise\Declaration\Visitor;
5
6
use PhpParser\Node;
7
use PhpParser\NodeVisitorAbstract;
8
9
class LocateProperties extends NodeVisitorAbstract
10
{
11
    /** @var string[] */
12
    private $properties = [];
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function leaveNode(Node $node)
18
    {
19
        if (!$node instanceof Node\Stmt\Property) {
20
            return null;
21
        }
22
23
        if ($node->isPrivate() || $node->isStatic()) {
24
            return null;
25
        }
26
27
        foreach ($node->props as $prop) {
28
            $this->properties[] = $prop->name->name;
29
        }
30
31
        return null;
32
    }
33
34
    public function getProperties(): array
35
    {
36
        return $this->properties;
37
    }
38
}