Total Complexity | 5 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class StrictJsonParser implements JsonParser |
||
11 | { |
||
12 | /** |
||
13 | * @inheritdoc |
||
14 | */ |
||
15 | public function encode(array $data): string |
||
16 | { |
||
17 | $json = json_encode($data); |
||
18 | |||
19 | if (json_last_error() !== JSON_ERROR_NONE) { |
||
20 | throw new JsonEncodingException(json_last_error_msg(), json_last_error()); |
||
21 | } |
||
22 | |||
23 | return $json; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @inheritdoc |
||
28 | */ |
||
29 | public function decode(string $json): array |
||
42 | } |
||
43 | } |
||
44 |