Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
1 | <?php |
||
24 | 3 | public function inject($object, string $property, $value) |
|
25 | { |
||
26 | 3 | if (!$this->supports($object, $property, $value)) { |
|
27 | 1 | throw new LogicException; |
|
28 | } |
||
29 | |||
30 | 2 | $refl = new \ReflectionObject($object); |
|
31 | 2 | $refl = $refl->getProperty($property); |
|
32 | |||
33 | 2 | if (!$refl->isPublic()) { |
|
34 | 2 | $refl->setAccessible(true); |
|
35 | } |
||
36 | |||
37 | 2 | $refl->setValue($object, $value); |
|
38 | |||
39 | 2 | if (!$refl->isPublic()) { |
|
40 | 2 | $refl->setAccessible(false); |
|
41 | } |
||
42 | 2 | } |
|
43 | } |
||
44 |