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