Conditions | 5 |
Paths | 1 |
Total Lines | 28 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
33 | public static function decider() |
||
34 | { |
||
35 | return function ( |
||
36 | $retries, |
||
37 | Request $request, |
||
38 | Response $response = null, |
||
39 | RequestException $exception = null |
||
40 | ) { |
||
41 | // Limit to 5 retry max |
||
42 | if ($retries >= 3) { |
||
43 | return false; |
||
44 | } |
||
45 | |||
46 | // Retry connection exceptions |
||
47 | if ($exception instanceof ConnectException) { |
||
48 | return true; |
||
49 | } |
||
50 | |||
51 | if ($response) { |
||
52 | // Retry if we have a serve error |
||
53 | if ($response->getStatusCode() >= 500) { |
||
54 | return true; |
||
55 | } |
||
56 | } |
||
57 | |||
58 | return false; |
||
59 | }; |
||
60 | } |
||
61 | |||
74 |