Total Complexity | 6 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class JsonResponse implements JsonResponseInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var array The JSON response data. |
||
15 | */ |
||
16 | protected $json = []; |
||
17 | |||
18 | /** |
||
19 | * @inheritDoc |
||
20 | */ |
||
21 | public function serialize(): string |
||
22 | { |
||
23 | $encoded = json_encode($this->json); |
||
24 | |||
25 | if (!is_string($encoded)) { |
||
|
|||
26 | throw new \RuntimeException("Cannot serialize JSON response message, failed encoding of JSON data."); |
||
27 | } |
||
28 | |||
29 | return $encoded; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @inheritDoc |
||
34 | */ |
||
35 | public function unserialize($serialized): void |
||
36 | { |
||
37 | $this->json = json_decode($serialized, true); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @inheritDoc |
||
42 | */ |
||
43 | public function parseResponseData($data): void |
||
56 | } |
||
57 | } |
||
58 |