Properties   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProperties() 0 15 3
A isIgnoredProperty() 0 4 2
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