Skip to content

RateLimitStatus

Raxos\RateLimit\RateLimitStatus

An immutable snapshot of a single rate limit check. It is the return type of RateLimiter::getStatus and reports how many operations have been recorded, which Rate applies, how long until the window resets, and whether the limit is exceeded.

php
final readonly class RateLimitStatus
{
    public bool $exceeded;

    public function __construct(int $operations, Rate $rate, int $ttl);
}

Constructor

__construct(int $operations, Rate $rate, int $ttl)

Creates a status. The exceeded property is computed in the constructor as operations greater than the rate quota.

Properties

PropertyTypeDescription
operationsintThe number of operations recorded so far in the current window.
rateRateThe rate that applies to this check.
ttlintThe remaining time to live in whole seconds until the window resets.
exceededboolTrue when operations is greater than rate->quota.

Example

php
<?php
declare(strict_types=1);

$status = $limiter->getStatus('api:user-42');

if ($status->exceeded) {
    $retryAfter = $status->ttl;
    $remaining = max(0, $status->rate->quota - $status->operations);
}

See also