public static function create(
        $type = self::GENERAL_RETRY_TYPE,
        $numberOfRetries = Resources::DEFAULT_NUMBER_OF_RETRIES,
        $interval = Resources::DEFAULT_RETRY_INTERVAL,
        $accumulationMethod = self::LINEAR_INTERVAL_ACCUMULATION,
        $retryConnect = false
    ) {
        //Validate the input parameters
        //type
        Validate::isTrue(
            $type == self::GENERAL_RETRY_TYPE ||
            $type == self::APPEND_BLOB_RETRY_TYPE,
            sprintf(
                Resources::INVALID_PARAM_GENERAL,
                'type'
            )
        );
        //numberOfRetries
        Validate::isTrue(
            $numberOfRetries > 0,
            sprintf(
                Resources::INVALID_NEGATIVE_PARAM,
                'numberOfRetries'
            )
        );
        //interval
        Validate::isTrue(
            $interval > 0,
            sprintf(
                Resources::INVALID_NEGATIVE_PARAM,
                'interval'
            )
        );
        //accumulationMethod
        Validate::isTrue(
            $accumulationMethod == self::LINEAR_INTERVAL_ACCUMULATION ||
            $accumulationMethod == self::EXPONENTIAL_INTERVAL_ACCUMULATION,
            sprintf(
                Resources::INVALID_PARAM_GENERAL,
                'accumulationMethod'
            )
        );
        //retryConnect
        Validate::isBoolean($retryConnect);

        //Get the interval calculator according to the type of the
        //accumulation method.
        $intervalCalculator =
            $accumulationMethod == self::LINEAR_INTERVAL_ACCUMULATION ?
            self::createLinearDelayCalculator($interval) :
            self::createExponentialDelayCalculator($interval);

        //Get the retry decider according to the type of the retry and
        //the number of retries.
        $retryDecider = self::createRetryDecider($type, $numberOfRetries, $retryConnect);

        //construct the retry middle ware.
        return new RetryMiddleware($intervalCalculator, $retryDecider);
    }
public static function create(
        $type = self::GENERAL_RETRY_TYPE,
        $numberOfRetries = Resources::DEFAULT_NUMBER_OF_RETRIES,
        $interval = Resources::DEFAULT_RETRY_INTERVAL,
        $accumulationMethod = self::LINEAR_INTERVAL_ACCUMULATION,
        $retryConnect = false
    ) {
        //Validate the input parameters
        //type
        Validate::isTrue(
            $type == self::GENERAL_RETRY_TYPE ||
            $type == self::APPEND_BLOB_RETRY_TYPE,
            sprintf(
                Resources::INVALID_PARAM_GENERAL,
                'type'
            )
        );
        //numberOfRetries
        Validate::isTrue(
            $numberOfRetries > 0,
            sprintf(
                Resources::INVALID_NEGATIVE_PARAM,
                'numberOfRetries'
            )
        );
        //interval
        Validate::isTrue(
            $interval > 0,
            sprintf(
                Resources::INVALID_NEGATIVE_PARAM,
                'interval'
            )
        );
        //accumulationMethod
        Validate::isTrue(
            $accumulationMethod == self::LINEAR_INTERVAL_ACCUMULATION ||
            $accumulationMethod == self::EXPONENTIAL_INTERVAL_ACCUMULATION,
            sprintf(
                Resources::INVALID_PARAM_GENERAL,
                'accumulationMethod'
            )
        );
        //retryConnect
        Validate::isBoolean($retryConnect);

        //Get the interval calculator according to the type of the
        //accumulation method.
        $intervalCalculator =
            $accumulationMethod == self::LINEAR_INTERVAL_ACCUMULATION ?
            self::createLinearDelayCalculator($interval) :
            self::createExponentialDelayCalculator($interval);

        //Get the retry decider according to the type of the retry and
        //the number of retries.
        $retryDecider = self::createRetryDecider($type, $numberOfRetries, $retryConnect);

        //construct the retry middle ware.
        return new RetryMiddleware($intervalCalculator, $retryDecider);
    }
public static function create ( $ type = self :: GENERAL_RETRY_TYPE , $ numberOfRetries = Resources :: DEFAULT_NUMBER_OF_RETRIES , $ interval = Resources :: DEFAULT_RETRY_INTERVAL , $ accumulationMethod = self :: LINEAR_INTERVAL_ACCUMULATION , $ retryConnect = false ) { //Validate the input parameters //type Validate :: isTrue ( $ type == self :: GENERAL_RETRY_TYPE || $ type == self :: APPEND_BLOB_RETRY_TYPE , sprintf ( Resources :: INVALID_PARAM_GENERAL , 'type' ) ) ; //numberOfRetries Validate :: isTrue ( $ numberOfRetries > 0 , sprintf ( Resources :: INVALID_NEGATIVE_PARAM , 'numberOfRetries' ) ) ; //interval Validate :: isTrue ( $ interval > 0 , sprintf ( Resources :: INVALID_NEGATIVE_PARAM , 'interval' ) ) ; //accumulationMethod Validate :: isTrue ( $ accumulationMethod == self :: LINEAR_INTERVAL_ACCUMULATION || $ accumulationMethod == self :: EXPONENTIAL_INTERVAL_ACCUMULATION , sprintf ( Resources :: INVALID_PARAM_GENERAL , 'accumulationMethod' ) ) ; //retryConnect Validate :: isBoolean ( $ retryConnect ) ; //Get the interval calculator according to the type of the //accumulation method. $ intervalCalculator = $ accumulationMethod == self :: LINEAR_INTERVAL_ACCUMULATION ? self :: createLinearDelayCalculator ( $ interval ) : self :: createExponentialDelayCalculator ( $ interval ) ; //Get the retry decider according to the type of the retry and //the number of retries. $ retryDecider = self :: createRetryDecider ( $ type , $ numberOfRetries , $ retryConnect ) ; //construct the retry middle ware. return new RetryMiddleware ( $ intervalCalculator , $ retryDecider ) ; }
Create the retry handler for the Guzzle client, according to the given
attributes.

@param  string $type                The type that controls the logic of
the decider of the retry handler.
Possible value can be
self::GENERAL_RETRY_TYPE or
self::APPEND_BLOB_RETRY_TYPE
@param  int    $numberOfRetries     The maximum number of retries.
@param  int    $interval            The minimum interval between each retry
@param  string $accumulationMethod  If the interval increases linearly or
exponentially.
Possible value can be
self::LINEAR_INTERVAL_ACCUMULATION or
self::EXPONENTIAL_INTERVAL_ACCUMULATION
@param  bool   $retryConnect        Whether to retry on connection failures.
@return RetryMiddleware             A RetryMiddleware object that contains
the logic of how the request should be
handled after a response.
Create the retry handler for the Guzzle client according to the given attributes .