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