Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
13 | 2 | public function encode($data) |
|
14 | { |
||
15 | 2 | $encodedJson = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
|
16 | |||
17 | 2 | if (JSON_ERROR_NONE !== json_last_error()) { |
|
18 | 1 | throw new UnexpectedValueException(json_last_error_msg()); |
|
19 | } else { |
||
20 | 1 | $encodedJson .= "\n"; |
|
21 | } |
||
22 | |||
23 | 1 | return $encodedJson; |
|
24 | } |
||
25 | |||
42 |