for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Ivory Http Adapter package.
*
* (c) Eric GELOEN <[email protected]>
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*/
namespace Ivory\HttpAdapter\Event\Retry\Strategy;
use Ivory\HttpAdapter\Message\InternalRequestInterface;
/**
* @author GeLo <[email protected]>
abstract class AbstractRetryStrategyChain implements RetryStrategyChainInterface
{
* @var RetryStrategyChainInterface
private $next;
* @param RetryStrategyChainInterface|null $next
public function __construct(RetryStrategyChainInterface $next = null)
$this->setNext($next);
}
* {@inheritdoc}
public function hasNext()
return $this->next !== null;
public function getNext()
return $this->next;
public function setNext(RetryStrategyChainInterface $next = null)
$this->next = $next;
public function verify(InternalRequestInterface $request)
$verify = $this->doVerify($request);
if ($verify && $this->hasNext()) {
return $this->next->verify($request);
return $verify;
public function delay(InternalRequestInterface $request)
$delay = $this->doDelay($request);
if ($this->hasNext() && (($nextDelay = $this->next->delay($request)) > $delay)) {
return $nextDelay;
return $delay;
* @param InternalRequestInterface $request
* @return bool
protected function doVerify(InternalRequestInterface $request)
return true;
* @return int
protected function doDelay(InternalRequestInterface $request)
return 0;