| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 22.22% |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class CouldNotSendNotification extends Exception |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @param \Psr\Http\Message\ResponseInterface $response |
||
| 13 | * |
||
| 14 | * @return static |
||
| 15 | */ |
||
| 16 | public static function serviceRespondedWithAnHttpError(ResponseInterface $response) |
||
| 17 | { |
||
| 18 | $message = "Discord responded with an HTTP error: {$response->getStatusCode()}"; |
||
| 19 | |||
| 20 | if ($error = Arr::get(json_decode($response->getBody(), true), 'message')) { |
||
| 21 | $message .= ": $error"; |
||
| 22 | } |
||
| 23 | |||
| 24 | return new static($message); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param array $response |
||
| 29 | * |
||
| 30 | * @return static |
||
| 31 | */ |
||
| 32 | public static function serviceRespondedWithAnApiError(array $response) |
||
| 33 | { |
||
| 34 | return new static("Discord responded with an API error: {$response['code']}: {$response['message']}"); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param \Exception $exception |
||
| 39 | * |
||
| 40 | * @return static |
||
| 41 | */ |
||
| 42 | 6 | public static function serviceCommunicationError(Exception $exception) |
|
| 45 | } |
||
| 46 | } |
||
| 47 |