Documentation

RateLimiter
in package
Uses InteractsWithTime

Table of Contents

$cache  : Repository
The cache store implementation.
__construct()  : void
Create a new rate limiter instance.
attempts()  : mixed
Get the number of attempts for the given key.
availableIn()  : int
Get the number of seconds until the "key" is accessible again.
clear()  : void
Clear the hits and lockout timer for the given key.
hit()  : int
Increment the counter for a given key for a given decay time.
resetAttempts()  : mixed
Reset the number of attempts for the given key.
retriesLeft()  : int
Get the number of retries left for the given key.
tooManyAttempts()  : bool
Determine if the given key has been "accessed" too many times.
availableAt()  : int
Get the "available at" UNIX timestamp.
currentTime()  : int
Get the current system time as a UNIX timestamp.
parseDateInterval()  : DateTimeInterface|int
If the given value is an interval, convert it to a DateTime instance.
secondsUntil()  : int
Get the number of seconds until the given DateTime.

Properties

Methods

attempts()

Get the number of attempts for the given key.

public attempts(string $key) : mixed
Parameters
$key : string
Return values
mixed

availableIn()

Get the number of seconds until the "key" is accessible again.

public availableIn(string $key) : int
Parameters
$key : string
Return values
int

clear()

Clear the hits and lockout timer for the given key.

public clear(string $key) : void
Parameters
$key : string
Return values
void

hit()

Increment the counter for a given key for a given decay time.

public hit(string $key[, float|int $decayMinutes = 1 ]) : int
Parameters
$key : string
$decayMinutes : float|int = 1
Return values
int

resetAttempts()

Reset the number of attempts for the given key.

public resetAttempts(string $key) : mixed
Parameters
$key : string
Return values
mixed

retriesLeft()

Get the number of retries left for the given key.

public retriesLeft(string $key, int $maxAttempts) : int
Parameters
$key : string
$maxAttempts : int
Return values
int

tooManyAttempts()

Determine if the given key has been "accessed" too many times.

public tooManyAttempts(string $key, int $maxAttempts[, float|int $decayMinutes = 1 ]) : bool
Parameters
$key : string
$maxAttempts : int
$decayMinutes : float|int = 1
Return values
bool

availableAt()

Get the "available at" UNIX timestamp.

protected availableAt(DateTimeInterface|DateInterval|int $delay) : int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
int

currentTime()

Get the current system time as a UNIX timestamp.

protected currentTime() : int
Return values
int

parseDateInterval()

If the given value is an interval, convert it to a DateTime instance.

protected parseDateInterval(DateTimeInterface|DateInterval|int $delay) : DateTimeInterface|int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
DateTimeInterface|int

secondsUntil()

Get the number of seconds until the given DateTime.

protected secondsUntil(DateTimeInterface|DateInterval|int $delay) : int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
int

Search results