NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Windows are modelled by the Timespan enum (second, minute, hour, day). It uses the shared RoundlyConsulting\Enums\Helpers trait from enums-for-laravel, so it exposes the full enum toolkit — handy for letting admins pick a window in a form:

use RoundlyConsulting\HttpClientRateLimits\Enums\Timespan;

Timespan::values();          // collection: ['second', 'minute', 'hour', 'day']
Timespan::labels();          // collection: ['Second', 'Minute', 'Hour', 'Day']
Timespan::options();         // list of {value, label, name} option DTOs
Timespan::toOptions();       // value => label map for <select> inputs
Timespan::validationRule();  // 'in:second,minute,hour,day'

Timespan::Hour->label();     // 'Hour'
Timespan::fromName('Hour');  // Timespan::Hour

Domain methods

Timespan::fromValue('minute');     // Timespan::Minute
Timespan::fromValue('week');       // throws InvalidTimespanException

Timespan::Hour->lengthInMs();      // 3600000

$limit = new Limit(maxAttempts: 10, timespan: Timespan::Hour); // enum or its string value

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.