---
title: "Timespan enum — HTTP Client Rate Limits for Laravel | Roundly"
description: "The Timespan enum behind every window — second to day — with the full enums-for-laravel toolkit for labels, options and validation."
url: https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel/timespan-enum
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[HTTP Client Rate Limits for Laravel](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)

# Timespan enum

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:

```php
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

```php
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](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel.md)
