| Total Complexity | 3 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | final class JsonSerializer implements SerializerInterface |
||
| 21 | { |
||
| 22 | private Serializer $serializer; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param int $options The encoding options. |
||
| 26 | * |
||
| 27 | * @see http://www.php.net/manual/en/function.json-encode.php |
||
| 28 | */ |
||
| 29 | 18 | public function __construct(int $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) |
|
| 30 | { |
||
| 31 | 18 | $this->serializer = new Serializer( |
|
| 32 | 18 | [new JsonSerializableNormalizer(), new ObjectNormalizer()], |
|
| 33 | 18 | [new JsonEncoder( |
|
| 34 | 18 | new JsonEncode([JsonEncode::OPTIONS => $options]), |
|
| 35 | 18 | new JsonDecode([JsonDecode::ASSOCIATIVE => true]), |
|
| 36 | )], |
||
| 37 | ); |
||
| 38 | 18 | } |
|
| 39 | |||
| 40 | 10 | public function serialize($value): string |
|
| 41 | { |
||
| 42 | 10 | return $this->serializer->serialize($value, JsonEncoder::FORMAT); |
|
| 43 | } |
||
| 44 | |||
| 45 | 9 | public function unserialize(string $value) |
|
| 48 | } |
||
| 49 | } |
||
| 50 |