master

laravel/framework

Last updated at: 29/12/2023 09:25

RateLimiter.php

TLDR

This file defines the RateLimiter facade class, which provides a simple and convenient way to use the RateLimiter functionality in Laravel.

Methods

for

This method sets up the rate limiter for a given name and callback.

limiter

This method returns the closure for a specified name.

attempt

This method attempts to execute the callback and, if it fails, increments the number of attempts for the specified key.

tooManyAttempts

This method checks if there have been too many attempts for the specified key.

hit

This method increments the number of hits for the specified key.

attempts

This method returns the number of attempts for the specified key.

resetAttempts

This method resets the number of attempts for the specified key.

remaining

This method returns the number of remaining attempts for the specified key.

retriesLeft

This method returns the number of retries left based on the maximum number of attempts.

clear

This method clears the rate limiter for the specified key.

availableIn

This method returns the number of seconds until the rate limiter becomes available for the specified key.

cleanRateLimiterKey

This method cleans the rate limiter key for the specified key.

Classes

There are no classes defined in this file.

<?php

namespace Illuminate\Support\Facades;

/**
 * @method static \Illuminate\Cache\RateLimiter for(string $name, \Closure $callback)
 * @method static \Closure|null limiter(string $name)
 * @method static mixed attempt(string $key, int $maxAttempts, \Closure $callback, int $decaySeconds = 60)
 * @method static bool tooManyAttempts(string $key, int $maxAttempts)
 * @method static int hit(string $key, int $decaySeconds = 60)
 * @method static mixed attempts(string $key)
 * @method static mixed resetAttempts(string $key)
 * @method static int remaining(string $key, int $maxAttempts)
 * @method static int retriesLeft(string $key, int $maxAttempts)
 * @method static void clear(string $key)
 * @method static int availableIn(string $key)
 * @method static string cleanRateLimiterKey(string $key)
 *
 * @see \Illuminate\Cache\RateLimiter
 */
class RateLimiter extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return \Illuminate\Cache\RateLimiter::class;
    }
}