| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class CouldNotSendNotification extends Exception |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @param \Psr\Http\Message\ResponseInterface $response |
||
| 13 | * @param int $code |
||
| 14 | * @param \Exception $exception |
||
| 15 | * |
||
| 16 | * @return static |
||
| 17 | */ |
||
| 18 | 1 | public static function serviceRespondedWithAnHttpError(ResponseInterface $response, $code, $exception) |
|
| 19 | { |
||
| 20 | 1 | $message = "Discord responded with an HTTP error: {$response->getStatusCode()}"; |
|
| 21 | |||
| 22 | 1 | if ($error = Arr::get(json_decode($response->getBody(), true), 'message')) { |
|
| 23 | 1 | $message .= ": $error"; |
|
| 24 | } |
||
| 25 | |||
| 26 | 1 | return new static($message, $code, $exception); |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param array $response |
||
| 31 | * @param int $code |
||
| 32 | * |
||
| 33 | * @return static |
||
| 34 | */ |
||
| 35 | 1 | public static function serviceRespondedWithAnApiError(array $response, $code, $exception = null) |
|
|
|
|||
| 36 | { |
||
| 37 | 1 | return new static("Discord responded with an API error: {$response['code']}: {$response['message']}", $code); |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param \Exception $exception |
||
| 42 | * |
||
| 43 | * @return static |
||
| 44 | */ |
||
| 45 | 2 | public static function serviceCommunicationError(Exception $exception) |
|
| 48 | } |
||
| 49 | } |
||
| 50 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.