1 | <?php |
||
19 | class JsonEventSerializer implements EventSerializer |
||
20 | { |
||
21 | /** |
||
22 | * JSON encoding options. |
||
23 | * Preserve float values and encode &, ', ", < and > characters in the resulting JSON. |
||
24 | */ |
||
25 | protected const JSON_ENCODE_OPTIONS = \JSON_UNESCAPED_UNICODE |
||
26 | | \JSON_UNESCAPED_SLASHES |
||
27 | | \JSON_PRESERVE_ZERO_FRACTION |
||
28 | | \JSON_HEX_AMP |
||
29 | | \JSON_HEX_APOS |
||
30 | | \JSON_HEX_QUOT |
||
31 | | \JSON_HEX_TAG; |
||
32 | |||
33 | /** |
||
34 | * JSON decoding options. |
||
35 | * Decode large integers as string values. |
||
36 | */ |
||
37 | protected const JSON_DECODE_OPTIONS = \JSON_BIGINT_AS_STRING; |
||
38 | |||
39 | /** |
||
40 | * \DateTime::RFC3339_EXTENDED cannot handle microseconds on \DateTimeImmutable::createFromFormat. |
||
41 | * |
||
42 | * @see https://stackoverflow.com/a/48949373 |
||
43 | */ |
||
44 | protected const DATE_RFC3339_EXTENDED = 'Y-m-d\TH:i:s.uP'; |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | final public function serialize(Event $event): string |
||
72 | |||
73 | /** |
||
74 | * Get serialization attributes. |
||
75 | * |
||
76 | * @param Event $event |
||
77 | * |
||
78 | * @return array<string, mixed> |
||
|
|||
79 | */ |
||
80 | protected function getSerializationAttributes(Event $event): array |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | final public function fromSerialized(string $serialized): Event |
||
116 | |||
117 | /** |
||
118 | * Get event definition from serialization. |
||
119 | * |
||
120 | * @param string $serialized |
||
121 | * |
||
122 | * @throws EventSerializationException |
||
123 | * |
||
124 | * @return array<string, mixed> |
||
125 | */ |
||
126 | private function getEventDefinition(string $serialized): array |
||
141 | |||
142 | /** |
||
143 | * Get deserialization definition. |
||
144 | * |
||
145 | * @param string $serialized |
||
146 | * |
||
147 | * @return array<string, mixed> |
||
148 | */ |
||
149 | private function getDeserializationDefinition(string $serialized): array |
||
169 | |||
170 | /** |
||
171 | * Get deserialization attributes. |
||
172 | * |
||
173 | * @param array<string, mixed> $attributes |
||
174 | * |
||
175 | * @return array<string, mixed> |
||
176 | */ |
||
177 | protected function getDeserializationAttributes(array $attributes): array |
||
183 | } |
||
184 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.