Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
38 | public function makeResponseData(HttpResponseInterface $response) |
||
39 | { |
||
40 | // Ensure application/json content type which indicates a JSON response. |
||
41 | if (stristr($response->getHeaderLine('Content-Type'), 'application/json') === false) { |
||
42 | throw new ClientException("Cannot read JSON response. The 'Content-Type' response header is not 'application/json'."); |
||
43 | } |
||
44 | |||
45 | // Get whole body contents of the response. |
||
46 | $bodyContents = $response->getBody()->getContents(); |
||
47 | |||
48 | // Expect a non-empty response body. |
||
49 | if (empty($bodyContents)) { |
||
50 | throw new ClientException("Cannot read JSON response. The response body is empty."); |
||
51 | } |
||
52 | |||
53 | return $bodyContents; |
||
54 | } |
||
56 |