Properties::isIgnoredProperty()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * Spiral Framework. Cycle ProxyFactory
5
 *
6
 * @license MIT
7
 * @author  Valentin V (Vvval)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\ORM\Promise\Declaration\Extractor;
13
14
use ReflectionClass;
15
use ReflectionProperty;
16
use SplObjectStorage;
17
18
final class Properties
19
{
20
    /**
21
     * @param ReflectionClass $reflection
22
     * @return SplObjectStorage
23
     */
24
    public function getProperties(ReflectionClass $reflection): SplObjectStorage
25
    {
26
        $properties = new SplObjectStorage();
27
        $defaults = $reflection->getDefaultProperties();
28
29
        foreach ($reflection->getProperties() as $property) {
30
            if ($this->isIgnoredProperty($property)) {
31
                continue;
32
            }
33
34
            $properties->attach($property, array_key_exists($property->getName(), $defaults));
35
        }
36
37
        return $properties;
38
    }
39
40
    /**
41
     * @param ReflectionProperty $property
42
     * @return bool
43
     */
44
    private function isIgnoredProperty(ReflectionProperty $property): bool
45
    {
46
        return $property->isPrivate() || $property->isStatic();
47
    }
48
}
49