Laravel: Throttling any method class elegantly

You only need one magic method

if (! $limiter->hasTooManyAttempts('doSomething', 3)) {
$class->doSomething();
$limiter->hit('doSomething', 60);
}

Throttling a class method? What magic is this?

$class->throttle()->doSomething();
$object->throttle()->doSomething()->somethingElse();

Graphic Designer graduate. Full Stack Web Developer. Retired Tech & Gaming Editor.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store