public function execute(callable $function, array $arguments = [])
{
$delayFunction = $this->delayFunction;
$retryAttempt = 0;
$exception = null;
while (true) {
try {
return call_user_func_array($function, $arguments);
} catch (\Exception $exception) {
if ($this->retryFunction) {
if (!call_user_func($this->retryFunction, $exception)) {
throw $exception;
}
}
if ($retryAttempt >= $this->retries) {
break;
}
$delayFunction($this->calculateDelay($retryAttempt));
$retryAttempt++;
}
}
throw $exception;
}
public static function tearDownFixtures() { $backoff = new ExponentialBackoff(8); foreach (self::$deletionQueue as $item) { $backoff->execute(function () use($item) { $item->delete(); }); } }