Conditions | 5 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
19 | 50 | public function create(\ReflectionClass $class, \ReflectionProperty $property) |
|
20 | { |
||
21 | 50 | if ($property->isStatic()) { |
|
22 | 1 | throw new \LogicException('Cannot create property access for static properties'); |
|
23 | } |
||
24 | |||
25 | // is it a public property |
||
26 | 49 | if ($property->isPublic()) { |
|
27 | 19 | return PublicPropertyAccess::create($property->name); |
|
28 | } |
||
29 | |||
30 | // can we you the reflection accessor |
||
31 | 47 | if ($property->isProtected() || |
|
32 | 47 | $property->getDeclaringClass()->name === $class->name) { |
|
33 | |||
34 | 46 | return ReflectionPropertyAccess::create($class, $property->name); |
|
35 | } |
||
36 | |||
37 | 38 | return ScopedPropertyAccess::create($property->getDeclaringClass()->name, $property->name); |
|
38 | } |
||
40 |