Conditions | 3 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | 3 | public function render(ResourceObject $ro) |
|
15 | { |
||
16 | 3 | if (! array_key_exists('content-type', $ro->headers)) { |
|
17 | 2 | $ro->headers['content-type'] = 'application/json'; |
|
18 | } |
||
19 | 3 | $ro->view = json_encode($ro, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL; |
|
20 | 3 | $e = json_last_error(); |
|
21 | 3 | if ($e) { |
|
22 | // @codeCoverageIgnoreStart |
||
23 | error_log('json_encode error: ' . json_last_error_msg() . ' in ' . __METHOD__); |
||
24 | |||
25 | return ''; |
||
26 | // @codeCoverageIgnoreEnd |
||
27 | } |
||
28 | |||
29 | 3 | return $ro->view; |
|
30 | } |
||
31 | } |
||
32 |