🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano
QueueClock — queue clock
Purpose
Serves pre-defined moments one by one; an exhausted queue raises a typed exception, so an extra now() call is visible immediately.
What for and how to use
Exact scenarios: “first call — 10:00, second — 10:05”. push() appends, remaining()/isEmpty() inspect.
Example
$clock = QueueClock::from('2026-01-01 10:00:00', '2026-01-01 10:05:00');
$clock->now(); // 10:00:00
$clock->now(); // 10:05:00
$clock->now(); // InvalidClockValueException: the queue is empty
Anti-patterns
Not for long loops with an unknown number of reads — the queue is finite by construction.
Lifecycle
flowchart LR
A[m1, m2, m3] -->|now| B(m1)
B -->|now| C(m2)
C -->|now| D(m3)
D -->|now| E[/InvalidClockValueException/]
Feature comparison with competitors
| Aspect | 🏆 CloudCastle | symfony | carbon | lcobucci | beste | ergebnis |
|---|---|---|---|---|---|---|
| Pre-defined moment sequence | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Exception on exhaustion | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
On-the-fly push() | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Head inspection without consumption | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Total | 🏆 4 | 0 | 0 | 0 | 0 | 0 |
🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano