| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Json implements EncoderInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @param mixed $data |
||
| 11 | * @throws Exception |
||
| 12 | * @return string |
||
| 13 | */ |
||
| 14 | 25 | public function encode($data): string |
|
| 15 | { |
||
| 16 | 25 | $res = json_encode($data); |
|
| 17 | |||
| 18 | 25 | if ($res === false) { |
|
| 19 | 1 | throw new Exception('Can not encode JSON'); |
|
| 20 | } |
||
| 21 | |||
| 22 | 24 | return $res; |
|
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param string $value |
||
| 27 | * @throws Exception |
||
| 28 | * @return mixed |
||
| 29 | */ |
||
| 30 | 17 | public function decode(string $value) |
|
| 39 | } |
||
| 40 | } |
||
| 41 |