1 | <?php |
||
23 | final class InteractionComponentNormalizer extends Normalizer implements DenormalizerInterface, NormalizerInterface |
||
24 | { |
||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | 8 | public function normalize($object, $format = null, array $context = array()) |
|
29 | { |
||
30 | 8 | if (!$object instanceof InteractionComponent) { |
|
31 | return; |
||
32 | } |
||
33 | |||
34 | $data = array( |
||
35 | 8 | 'id' => $object->getId(), |
|
36 | ); |
||
37 | |||
38 | 8 | if (null !== $description = $object->getDescription()) { |
|
39 | 1 | $data['description'] = $this->normalizeAttribute($description, $format, $context); |
|
40 | } |
||
41 | |||
42 | 8 | return $data; |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 121 | public function supportsNormalization($data, $format = null) |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 8 | public function denormalize($data, $class, $format = null, array $context = array()) |
|
57 | { |
||
58 | 8 | $description = null; |
|
59 | |||
60 | 8 | if (isset($data['description'])) { |
|
61 | 1 | $description = $this->denormalizeData($data['description'], 'Xabbuh\XApi\Model\LanguageMap', $format, $context); |
|
62 | } |
||
63 | |||
64 | 8 | return new InteractionComponent($data['id'], $description); |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 127 | public function supportsDenormalization($data, $type, $format = null) |
|
74 | } |
||
75 |