Conditions | 4 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
18 | 11 | public function render(mixed $data, mixed ...$args): string |
|
19 | { |
||
20 | 11 | $flags = JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR; |
|
21 | |||
22 | 11 | if (count($args) > 0) { |
|
23 | /** @var mixed */ |
||
24 | 1 | $arg = $args[array_key_first($args)]; |
|
25 | |||
26 | 1 | if (is_int($arg)) { |
|
27 | 1 | $flags = $arg; |
|
28 | } |
||
29 | } |
||
30 | |||
31 | 11 | if ($data instanceof Traversable) { |
|
32 | 2 | return json_encode(iterator_to_array($data), $flags); |
|
33 | } |
||
34 | |||
35 | 10 | return json_encode($data, $flags); |
|
36 | } |
||
47 |