Conditions | 5 |
Paths | 1 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
20 | public static function decider() |
||
21 | { |
||
22 | return function ( |
||
23 | $retries, |
||
24 | Request $request, |
||
25 | Response $response = null, |
||
26 | RequestException $exception = null |
||
27 | ) { |
||
28 | // Limit to 5 retry max |
||
29 | if ($retries >= 3) { |
||
30 | return false; |
||
31 | } |
||
32 | |||
33 | // Retry connection exceptions |
||
34 | if ($exception instanceof ConnectException) { |
||
35 | return true; |
||
36 | } |
||
37 | |||
38 | if ($response) { |
||
39 | // Retry if we have a serve error |
||
40 | if ($response->getStatusCode() >= 500) { |
||
41 | return true; |
||
42 | } |
||
43 | } |
||
44 | |||
45 | return false; |
||
46 | }; |
||
47 | } |
||
48 | |||
61 |