| Total Complexity | 6 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 94.44% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | trait HandlesJson |
||
| 15 | { |
||
| 16 | |||
| 17 | |||
| 18 | /** |
||
| 19 | * @param mixed $data |
||
| 20 | * @return string |
||
| 21 | * @throws ArangoException |
||
| 22 | */ |
||
| 23 | 72 | public function jsonEncode(mixed $data): string |
|
| 24 | { |
||
| 25 | 72 | $options = 0; |
|
| 26 | 72 | if (empty($data)) { |
|
| 27 | 3 | $options = JSON_FORCE_OBJECT; |
|
| 28 | } |
||
| 29 | |||
| 30 | 72 | $response = json_encode($data, $options); |
|
| 31 | |||
| 32 | 72 | if ($response === false) { |
|
| 33 | 1 | throw new ArangoException('JSON encoding failed with error: ' . json_last_error_msg(), json_last_error()); |
|
| 34 | } |
||
| 35 | |||
| 36 | 71 | return $response; |
|
| 37 | } |
||
| 38 | |||
| 39 | |||
| 40 | /** |
||
| 41 | * @psalm-suppress MixedAssignment, MixedArrayOffset |
||
| 42 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
| 43 | * |
||
| 44 | * @param ResponseInterface|null $response |
||
| 45 | * @return stdClass |
||
| 46 | */ |
||
| 47 | 105 | protected function decodeResponse(?ResponseInterface $response): stdClass |
|
| 63 | } |
||
| 64 | } |
||
| 65 |