| 1 | <?php |
||
| 11 | class RenameHandler extends AbstractHandler implements HandlerInterface |
||
| 12 | { |
||
| 13 | 4 | public function hydrate(AnnotationInterface $annotation, array $json, ResourceInterface $object): array |
|
| 14 | { |
||
| 15 | 4 | if (!($annotation instanceof Rename)) { |
|
| 16 | return $json; |
||
| 17 | } |
||
| 18 | |||
| 19 | 4 | foreach ($annotation->properties() as $property) { |
|
| 20 | 4 | if (!isset($json[$annotation->get($property)])) { |
|
| 21 | continue; |
||
| 22 | } |
||
| 23 | |||
| 24 | 4 | $json[$property] = $json[$annotation->get($property)]; |
|
| 25 | 4 | unset($json[$annotation->get($property)]); |
|
| 26 | } |
||
| 27 | |||
| 28 | 4 | return $json; |
|
| 29 | } |
||
| 30 | |||
| 31 | 2 | public function extract(AnnotationInterface $annotation, ResourceInterface $object, array $json): array |
|
| 44 | } |
||
| 45 |