| Conditions | 4 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function createFromResponse(DataResponse $response): ApiResponseData |
||
| 14 | { |
||
| 15 | if ($response->getStatusCode() !== Status::OK) { |
||
| 16 | return $this |
||
| 17 | ->createErrorResponse() |
||
| 18 | ->setErrorCode($response->getStatusCode()) |
||
| 19 | ->setErrorMessage($this->getErrorMessage($response)); |
||
| 20 | } |
||
| 21 | |||
| 22 | $data = $response->getData(); |
||
| 23 | |||
| 24 | if ($data !== null && !is_array($data)) { |
||
| 25 | throw new RuntimeException('The response data must be either null or an array'); |
||
| 26 | } |
||
| 27 | |||
| 28 | return $this |
||
| 29 | ->createSuccessResponse() |
||
| 30 | ->setData($data); |
||
| 31 | } |
||
| 62 |