Conditions | 3 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 3.0416 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | 34 | public static function encode($value): string |
|
34 | { |
||
35 | 34 | $flags = \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | \JSON_PRESERVE_ZERO_FRACTION; |
|
36 | |||
37 | 34 | $json = \json_encode($value, $flags); |
|
38 | |||
39 | 34 | if ((JSON_ERROR_NONE !== $error = \json_last_error()) || $json === false) { |
|
40 | throw new JsonException(\json_last_error_msg(), $error); |
||
41 | } |
||
42 | |||
43 | 34 | return $json; |
|
44 | } |
||
65 |