| Conditions | 3 |
| Paths | 4 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 49 | 7 | public function negociate(Request $request, array $data = [], $status = Response::HTTP_OK) |
|
| 50 | { |
||
| 51 | 7 | $acceptHeader = $request->getHeader('Accept') ? $request->getHeader('Accept') : 'application/json'; |
|
| 52 | 7 | $priorities = ['application/json', 'text/html; charset=UTF-8']; |
|
| 53 | 7 | $mediaType = $this->negotiator->getBest($acceptHeader, $priorities); |
|
| 54 | 7 | $value = $mediaType->getValue(); |
|
| 55 | 7 | if ($value == 'text/html; charset=UTF-8') { |
|
| 56 | 2 | return new Response(print_r($data, true), $status); |
|
| 57 | } |
||
| 58 | |||
| 59 | 5 | return new JsonResponse($data, $status); |
|
|
|
|||
| 60 | } |
||
| 61 | } |
||
| 62 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: