Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
63 | 4 | public function convert($records): string |
|
64 | { |
||
65 | 4 | $records = $this->filterIterable($records); |
|
66 | 4 | if (!is_array($records)) { |
|
67 | 4 | $records = iterator_to_array($records); |
|
68 | } |
||
69 | |||
70 | 4 | $json = @json_encode($records, $this->options, 2); |
|
71 | 4 | if (JSON_ERROR_NONE === json_last_error()) { |
|
72 | 2 | return $json; |
|
73 | } |
||
74 | |||
75 | 2 | throw new RuntimeException(json_last_error_msg()); |
|
76 | } |
||
77 | } |
||
78 |