| Conditions | 3 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 16 |
| Ratio | 100 % |
| Tests | 6 |
| CRAP Score | 3.1406 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 9 | View Code Duplication | public static function encode($value) |
| 18 | { |
||
| 19 | set_error_handler(function () use ($value) { |
||
| 20 | throw new JsonEncodeException($value); |
||
| 21 | 9 | }); |
|
| 22 | |||
| 23 | 9 | $json = json_encode($value); |
|
| 24 | |||
| 25 | 9 | if ('null' === $json && $value !== null) { |
|
| 26 | throw new JsonEncodeException($value); |
||
| 27 | } |
||
| 28 | |||
| 29 | 9 | restore_error_handler(); |
|
| 30 | |||
| 31 | 9 | return $json; |
|
| 32 | } |
||
| 33 | |||
| 51 |