ExponentialStrategy.php 409 B

12345678910111213141516171819202122
  1. <?php
  2. namespace STS\Backoff\Strategies;
  3. /**
  4. * Class ExponentialStrategy
  5. * @package STS\Backoff\Strategies
  6. */
  7. class ExponentialStrategy extends AbstractStrategy
  8. {
  9. /**
  10. * @param int $attempt
  11. *
  12. * @return int
  13. */
  14. public function getWaitTime($attempt)
  15. {
  16. return (int) ($attempt == 1
  17. ? $this->base
  18. : pow(2, $attempt) * $this->base
  19. );
  20. }
  21. }