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