| Conditions | 7 |
| Paths | 7 |
| Total Lines | 29 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | protected function processResponseData() |
||
| 42 | { |
||
| 43 | $responseContent = $this->response->getContent(); |
||
| 44 | $contentType = $this->response->getHeader('Content-Type'); |
||
| 45 | $parts = explode(';', $contentType); |
||
|
|
|||
| 46 | |||
| 47 | switch ($parts[0]) { |
||
| 48 | case 'application/json': |
||
| 49 | case 'text/json': |
||
| 50 | return json_decode($responseContent, true); |
||
| 51 | break; |
||
| 52 | case 'application/x-www-form-urlencoded': |
||
| 53 | if (false === strpos($responseContent, '=')) { |
||
| 54 | /* Sometimes Discogs returns text/plain with this content type ... */ |
||
| 55 | return $responseContent; |
||
| 56 | } |
||
| 57 | $data = []; |
||
| 58 | parse_str($responseContent, $data); |
||
| 59 | return $data; |
||
| 60 | break; |
||
| 61 | case 'text/plain': |
||
| 62 | case 'text/html': |
||
| 63 | return $responseContent; |
||
| 64 | break; |
||
| 65 | default: |
||
| 66 | throw new \WebServCo\Api\Exceptions\ApiException( |
||
| 67 | sprintf('Api returned unsupported content type: %s.', $contentType) |
||
| 68 | ); |
||
| 69 | break; |
||
| 70 | } |
||
| 73 |