Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
[RateLimit] Allow to get RateLimit without consuming again.
  • Loading branch information
ERuban committed Dec 17, 2023
commit 717b3822d47ace83cd3f5c9bc6c3d8ec492116fd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function reserve(int $tokens = 1, float $maxTime = null): Reservation
$now = microtime(true);
$hitCount = $window->getHitCount();
$availableTokens = $this->getAvailableTokens($hitCount);
if ($tokens !== 0 && $availableTokens >= $tokens) {
if (0 !== $tokens && $availableTokens >= $tokens) {
$window->add($tokens);

$reservation = new Reservation($now, new RateLimit($this->getAvailableTokens($window->getHitCount()), \DateTimeImmutable::createFromFormat('U', floor($now)), true, $this->limit));
Expand Down