🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano
ScaledClock — scaled clock
Purpose
Decorator: virtual time flows faster (scale > 1) or slower (scale < 1) than real time from the creation point.
What for and how to use
Simulations and demos: “a day per minute”, accelerated checks of schedule-driven scenarios.
Example
$fast = new ScaledClock(SystemClock::utc(), 60.0); // a minute becomes an hour
sleep(1);
$fast->now(); // about a minute later in virtual time
Anti-patterns
Non-positive scale is rejected with an exception; to stop time use FrozenClock.
Lifecycle
flowchart LR
A[Inner clock] -->|delta| B[ScaledClock]
B -->|delta x scale| C[Virtual moment]
C --> D[Consumer]
Feature comparison with competitors
| Aspect | 🏆 CloudCastle | symfony | carbon | lcobucci | beste | ergebnis |
|---|---|---|---|---|---|---|
| Speeding up / slowing down time | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Scale validated with an exception | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Anchor fixed at creation | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Composes with mocks for tests | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Total | 🏆 4 | 0 | 0 | 0 | 0 | 0 |
🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano