| Total Complexity | 4 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class Json |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Returns the JSON representation of a value |
||
| 16 | * |
||
| 17 | * @static |
||
| 18 | * @param mixed $value |
||
| 19 | * @param int $options |
||
| 20 | * @param int $depth |
||
| 21 | * @return string |
||
| 22 | * @throws JsonParseException |
||
| 23 | */ |
||
| 24 | public static function encode($value, $options = 0, $depth = 512) |
||
| 25 | { |
||
| 26 | $json = \json_encode($value, $options, $depth); |
||
| 27 | if (JSON_ERROR_NONE !== json_last_error()) { |
||
| 28 | throw new JsonParseException( |
||
| 29 | 'json_encode error: ' . json_last_error_msg(), |
||
| 30 | json_last_error() |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $json; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Decodes a JSON string |
||
| 39 | * |
||
| 40 | * @static |
||
| 41 | * @param string $json |
||
| 42 | * @param bool $assoc |
||
| 43 | * @param int $depth |
||
| 44 | * @param int $options |
||
| 45 | * @return mixed |
||
| 46 | * @throws JsonParseException |
||
| 47 | */ |
||
| 48 | public static function decode($json, $assoc = false, $depth = 512, $options = 0) |
||
| 59 | } |
||
| 60 | } |
||
| 61 |