Conditions | 4 |
Paths | 6 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4.0312 |
Changes | 0 |
1 | <?php |
||
18 | 4 | public function getResponse($data, array $acceptedMIMETypes): APIResponse |
|
19 | { |
||
20 | 4 | if (empty($acceptedMIMETypes)) { |
|
21 | $acceptedMIMETypes = $this->getSupportedMIMETypes(); |
||
22 | } |
||
23 | |||
24 | 4 | foreach ($acceptedMIMETypes as $acceptedMIMEType) { |
|
25 | 4 | switch (strtolower($acceptedMIMEType)) { |
|
26 | 4 | case "application/json": |
|
27 | 4 | return new JSONResponse($data); |
|
28 | } |
||
29 | } |
||
30 | |||
31 | 1 | throw new NotAcceptableResponseTypeException("None of the accepted types are supported"); |
|
32 | } |
||
33 | |||
44 |