Conditions | 5 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | 34 | public static function shouldRetry( |
|
19 | int $retries, |
||
20 | RequestInterface $request, |
||
21 | ?ResponseInterface $response, |
||
22 | ?GuzzleException $reason |
||
23 | ): bool { |
||
24 | 34 | if ($retries >= 2) { |
|
25 | 1 | return false; |
|
26 | } |
||
27 | |||
28 | 34 | if ($reason instanceof ConnectException) { |
|
29 | 1 | return true; |
|
30 | } |
||
31 | |||
32 | 34 | if ($response !== null && (int)floor($response->getStatusCode() / 100) === 5) { |
|
33 | 1 | return true; |
|
34 | } |
||
35 | |||
36 | 34 | return false; |
|
37 | } |
||
40 |