CodeExplorer getMinimalRateLimit example
private function doConsume(Request
$request, int
$tokens): RateLimit
{ $limiters =
$this->
getLimiters($request);
if (0 === \
count($limiters)) { $limiters =
[new NoLimiter()];
} $minimalRateLimit = null;
foreach ($limiters as $limiter) { $rateLimit =
$limiter->
consume($tokens);
$minimalRateLimit =
$minimalRateLimit ? self::
getMinimalRateLimit($minimalRateLimit,
$rateLimit) :
$rateLimit;
} return $minimalRateLimit;
} public function reset(Request
$request): void
{ foreach ($this->
getLimiters($request) as $limiter) { $limiter->
reset();
} } private function doConsume(Request
$request, int
$tokens): RateLimit
{ $limiters =
$this->
getLimiters($request);
if (0 === \
count($limiters)) { $limiters =
[new NoLimiter()];
} $minimalRateLimit = null;
foreach ($limiters as $limiter) { $rateLimit =
$limiter->
consume($tokens);
$minimalRateLimit =
$minimalRateLimit ? self::
getMinimalRateLimit($minimalRateLimit,
$rateLimit) :
$rateLimit;
} return $minimalRateLimit;
} public function reset(Request
$request): void
{ foreach ($this->
getLimiters($request) as $limiter) { $limiter->
reset();
} }