Total Complexity | 5 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class ClubCollectApiException extends \Exception |
||
14 | { |
||
15 | //-------------------------------------------------------------------------------------------------------------------- |
||
16 | use FormattedException; |
||
17 | |||
18 | //-------------------------------------------------------------------------------------------------------------------- |
||
19 | /** |
||
20 | * Creates an exception given a Guzzle exception. |
||
21 | * |
||
22 | * @param GuzzleException $exception The Guzzle exception. |
||
23 | * |
||
24 | * @return static |
||
25 | * |
||
26 | * @throws static |
||
27 | */ |
||
28 | public static function createFromGuzzleException(GuzzleException $exception): self |
||
29 | { |
||
30 | if (method_exists($exception, 'hasResponse') && method_exists($exception, 'getResponse')) |
||
31 | { |
||
32 | if ($exception->hasResponse()) |
||
33 | { |
||
34 | return static::createFromResponse($exception->getResponse()); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | return new static([$exception->getCode()], $exception->getMessage()); |
||
39 | } |
||
40 | |||
41 | //-------------------------------------------------------------------------------------------------------------------- |
||
42 | /** |
||
43 | * Creates an exception given the response from the http client. |
||
44 | * |
||
45 | * @param ResponseInterface $response The response from the http client. |
||
46 | * |
||
47 | * @return static |
||
48 | */ |
||
49 | public static function createFromResponse(ResponseInterface $response): self |
||
55 | } |
||
56 | |||
61 |