| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public static function fromBadResponseException(BadResponseException $e) |
||
| 21 | { |
||
| 22 | $message = 'An error has occurred during the API call'; |
||
| 23 | |||
| 24 | if ($e->getResponse() instanceof ResponseInterface) { |
||
| 25 | $body = (string) $e->getResponse()->getBody(); |
||
| 26 | $json = json_decode($body, true); |
||
| 27 | |||
| 28 | if (isset($json['message'])) { |
||
| 29 | $message = $json['message']; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | return new self($message); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |