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

LocateProperties::leaveNode()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4222
c 0
b 0
f 0
cc 5
nc 4
nop 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
}