Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | 79 | public function jsonEncode(mixed $data): string |
|
20 | { |
||
21 | 79 | $options = 0; |
|
22 | 79 | if (empty($data)) { |
|
23 | 3 | $options = JSON_FORCE_OBJECT; |
|
24 | } |
||
25 | |||
26 | 79 | $response = json_encode($data, $options); |
|
27 | |||
28 | 79 | if ($response === false) { |
|
29 | 1 | throw new ArangoException('JSON encoding failed with error: ' . json_last_error_msg(), json_last_error()); |
|
30 | } |
||
31 | |||
32 | 78 | return $response; |
|
33 | } |
||
59 |