| Conditions | 3 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 67 | 60 | public function buildJsonResponse(ResponseInterface $response) |
|
| 68 | { |
||
| 69 | 60 | $this->headers['content-type'] = 'application/json'; |
|
| 70 | |||
| 71 | 60 | foreach ($this->headers as $key => $value) { |
|
| 72 | 60 | $response = $response->withAddedHeader($key, $value); |
|
| 73 | 60 | } |
|
| 74 | |||
| 75 | 60 | if ($response->getBody()->isWritable()) { |
|
| 76 | 60 | $response->getBody()->write(json_encode([ |
|
| 77 | 60 | 'status_code' => $this->status, |
|
| 78 | 60 | 'reason_phrase' => $this->message |
|
| 79 | 60 | ])); |
|
| 80 | 60 | } |
|
| 81 | |||
| 82 | 60 | return $response->withStatus($this->status, $this->message); |
|
| 83 | } |
||
| 84 | } |
||
| 85 |