| Conditions | 4 |
| Paths | 4 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | private function writeJson(ResponseInterface $response, $payload, int $code = 200): ResponseInterface |
||
| 31 | { |
||
| 32 | if ($payload instanceof JsonSerializable) { |
||
| 33 | $payload = $payload->jsonSerialize(); |
||
| 34 | } |
||
| 35 | |||
| 36 | if (is_array($payload) && isset($payload['status'])) { |
||
| 37 | $code = $payload['status']; |
||
| 38 | } |
||
| 39 | |||
| 40 | $response->getBody()->write(json_encode($payload)); |
||
| 41 | |||
| 42 | return $response->withStatus($code)->withHeader('Content-Type', 'application/json'); |
||
| 43 | } |
||
| 45 |