base = $base; $this->cap = $cap; $this->withJitter = $withJitter; } /** * {@inheritDoc} */ public function compute(int $failures): int { if ($this->withJitter) { return min($this->cap, (mt_rand(0, mt_getrandmax() - 1) / mt_getrandmax()) * ($this->base * 2 ** $failures)); } if ($this->cap > 0) { return min($this->cap, $this->base * 2 ** $failures); } return $this->base * 2 ** $failures; } /** * @return int */ public function getBase(): int { return $this->base; } /** * @return int */ public function getCap(): int { return $this->cap; } }