| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 3 | public function format($content, int $statusCode): Response |
|
| 25 | { |
||
| 26 | 3 | $response = new JsonResponse(null, $statusCode); |
|
| 27 | |||
| 28 | 3 | if (true === in_array($statusCode, range(400, 599), true)) { |
|
| 29 | 2 | $response->headers->set('Content-Type', 'application/problem+json'); |
|
| 30 | 2 | $response->setData(['errors' => [$content]]); |
|
| 31 | } else { |
||
| 32 | 1 | $response->setData(['data' => $content]); |
|
| 33 | } |
||
| 34 | |||
| 35 | 3 | return $response; |
|
| 36 | } |
||
| 38 |