@@ 13-25 (lines=13) @@ | ||
10 | ||
11 | class RenameHandler extends AbstractHandler implements HandlerInterface |
|
12 | { |
|
13 | public function hydrate(AnnotationInterface $annotation, array $json, ResourceInterface $object): array |
|
14 | { |
|
15 | if (!($annotation instanceof Rename)) { |
|
16 | return $json; |
|
17 | } |
|
18 | ||
19 | foreach ($annotation->properties() as $property) { |
|
20 | $json[$property] = $json[$annotation->get($property)]; |
|
21 | unset($json[$annotation->get($property)]); |
|
22 | } |
|
23 | ||
24 | return $json; |
|
25 | } |
|
26 | ||
27 | public function extract(AnnotationInterface $annotation, ResourceInterface $object, array $json): array |
|
28 | { |
|
@@ 27-39 (lines=13) @@ | ||
24 | return $json; |
|
25 | } |
|
26 | ||
27 | public function extract(AnnotationInterface $annotation, ResourceInterface $object, array $json): array |
|
28 | { |
|
29 | if (!($annotation instanceof Rename)) { |
|
30 | return $json; |
|
31 | } |
|
32 | ||
33 | foreach ($annotation->properties() as $property) { |
|
34 | $json[$annotation->get($property)] = $json[$property]; |
|
35 | unset($json[$property]); |
|
36 | } |
|
37 | ||
38 | return $json; |
|
39 | } |
|
40 | } |
|
41 |