| Conditions | 4 |
| Paths | 4 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | protected function formatJson($response) |
||
| 16 | { |
||
| 17 | // If we have requested an endpoint that returns json with a preferred format |
||
| 18 | // of text/html instead of application/json then we are probably browsing the API |
||
| 19 | // and therefore want a prettier version of the response. |
||
| 20 | $acceptableContentTypes = array_keys(neon()->request->getAcceptableContentTypes()); |
||
| 21 | $contentTypeIsHtml = (isset($acceptableContentTypes[0]) && $acceptableContentTypes[0] === 'text/html'); |
||
| 22 | $prettyGetVarExists = (neon()->request->get('_pretty', false) !== false); |
||
| 23 | if ($contentTypeIsHtml || $prettyGetVarExists) { |
||
| 24 | $this->prettyPrint = true; |
||
| 25 | } |
||
| 26 | parent::formatJson($response); |
||
| 27 | } |
||
| 28 | } |