Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
31 | 6 | public function inject(object $object, string $property, $value): object |
|
32 | { |
||
33 | 6 | if (!$this->supports($object, $property, $value)) { |
|
34 | 1 | throw new LogicException; |
|
35 | } |
||
36 | |||
37 | 5 | $refl = (new AccessProperty)($object, $property); |
|
38 | |||
39 | 5 | if (!$refl->isPublic()) { |
|
40 | 5 | $refl->setAccessible(true); |
|
41 | } |
||
42 | |||
43 | 5 | $refl->setValue($object, $value); |
|
44 | |||
45 | 5 | if (!$refl->isPublic()) { |
|
46 | 5 | $refl->setAccessible(false); |
|
47 | } |
||
48 | |||
49 | 5 | return $object; |
|
50 | } |
||
52 |