Total Complexity | 7 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 4 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
8 | final class AccessProperty |
||
9 | { |
||
10 | /** |
||
11 | * @throws PropertyNotFound |
||
12 | */ |
||
13 | public function __invoke(object $object, string $property): \ReflectionProperty |
||
14 | { |
||
15 | try { |
||
16 | 23 | return $this->byObject($object, $property); |
|
17 | } catch (PropertyNotFound $e) { |
||
18 | return $this->byClass(\get_class($object), $property); |
||
19 | 23 | } |
|
20 | 12 | } |
|
21 | 12 | ||
22 | private function byObject(object $object, string $property): \ReflectionProperty |
||
31 | } |
||
32 | |||
33 | 12 | /** |
|
34 | * @param class-string $class |
||
|
|||
35 | */ |
||
36 | 12 | private function byClass(string $class, string $property): \ReflectionProperty |
|
52 | } |
||
53 | } |
||
54 |