Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
16 | public static function workplaceRespondedWithAnError(ClientException $exception) |
||
17 | { |
||
18 | $statusCode = $exception->getResponse()->getStatusCode(); |
||
19 | $description = 'No description given'; |
||
20 | if ($result = json_decode($exception->getResponse()->getBody())) { |
||
21 | $description = $result->description ?? $description; |
||
22 | } |
||
23 | |||
24 | return new static("Workplace responded with an error `{$statusCode} - {$description}`"); |
||
25 | } |
||
26 | |||
47 |