src/GuzzleFactory.php
public static function handler(int $backoff = null, array $codes = null, HandlerStack $stack = null)
    {
        $stack = $stack ?: HandlerStack::create();

        $stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) use ($codes) {
            return $retries < 3 && ($exception instanceof ConnectException || ($response && ($response->getStatusCode() >= 500 || in_array($response->getStatusCode(), $codes === null ? self::CODES : $codes, true))));
        }, function ($retries) use ($backoff) {
            return (int) pow(2, $retries) * ($backoff === null ? self::BACKOFF : $backoff);
        }));

        return $stack;
    }
public static function handler(int $backoff = null, array $codes = null, HandlerStack $stack = null)
    {
        $stack = $stack ?: HandlerStack::create();

        $stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) use ($codes) {
            return $retries < 3 && ($exception instanceof ConnectException || ($response && ($response->getStatusCode() >= 500 || in_array($response->getStatusCode(), $codes === null ? self::CODES : $codes, true))));
        }, function ($retries) use ($backoff) {
            return (int) pow(2, $retries) * ($backoff === null ? self::BACKOFF : $backoff);
        }));

        return $stack;
    }
public static function handler ( int $ backoff = null , array $ codes = null , HandlerStack $ stack = null ) { $ stack = $ stack ? : HandlerStack :: create ( ) ; $ stack -> push ( Middleware :: retry ( function ( $ retries , RequestInterface $ request , ResponseInterface $ response = null , TransferException $ exception = null ) use ( $ codes ) { return $ retries < 3 && ( $ exception instanceof ConnectException || ( $ response && ( $ response -> getStatusCode ( ) >= 500 || in_array ( $ response -> getStatusCode ( ) , $ codes === null ? self :: CODES : $ codes , true ) ) ) ) ; } , function ( $ retries ) use ( $ backoff ) { return ( int ) pow ( 2 , $ retries ) * ( $ backoff === null ? self :: BACKOFF : $ backoff ) ; } ) ) ; return $ stack ; }
Create a new guzzle handler stack.

@param int|null                      $backoff
@param int[]|null                    $codes
@param \GuzzleHttp\HandlerStack|null $stack

@return \GuzzleHttp\HandlerStack
Create a new guzzle handler stack .