| Total Complexity | 7 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | final class MethodAccessor implements AccessorInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | private $property; |
||
| 15 | |||
| 16 | public function __construct(string $property) |
||
| 17 | { |
||
| 18 | $this->property = $property; |
||
| 19 | 6 | } |
|
| 20 | |||
| 21 | 6 | /** |
|
| 22 | 6 | * @param object $object |
|
| 23 | * @param mixed $value |
||
| 24 | * |
||
| 25 | * @throws DeserializerLogicException |
||
| 26 | */ |
||
| 27 | public function setValue($object, $value) |
||
| 28 | { |
||
| 29 | $set = 'set'.ucfirst($this->property); |
||
| 30 | 2 | if (!method_exists($object, $set)) { |
|
| 31 | throw DeserializerLogicException::createMissingMethod(get_class($object), [$set]); |
||
| 32 | 2 | } |
|
| 33 | 2 | ||
| 34 | 1 | return $object->{$set}($value); |
|
| 35 | } |
||
| 36 | |||
| 37 | 1 | /** |
|
| 38 | * @param object $object |
||
| 39 | * |
||
| 40 | * @throws DeserializerLogicException |
||
| 41 | * |
||
| 42 | * @return mixed |
||
| 43 | */ |
||
| 44 | public function getValue($object) |
||
| 63 | } |
||
| 64 | } |
||
| 65 |