| Conditions | 5 |
| Paths | 1 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public static function make(array $options = [], int $backoff = 1000): Client |
||
| 21 | { |
||
| 22 | $stack = HandlerStack::create(); |
||
| 23 | $stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) { |
||
| 24 | return $retries < 3 && ($exception instanceof ConnectException || ($response && ($response->getStatusCode() >= 500 || $response->getStatusCode() === 429))); |
||
| 25 | }, function ($retries) use ($backoff) { |
||
| 26 | return (int) 2 ** $retries * $backoff; |
||
| 27 | })); |
||
| 28 | |||
| 29 | return new Client(array_merge(['handler' => $stack, 'connect_timeout' => 10, 'timeout' => 15], $options)); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |