CloudCastle Clock

🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano

CallbackClock — callback clock

Purpose

The moment source is an arbitrary closure: a bridge to non-standard time sources (external service, scenario generator).

What for and how to use

Integrate a foreign time API or complex moment logic without writing your own clock class.

Example

$clock = new CallbackClock(
    fn (): DateTimeImmutable => $externalTimeService->current(),
    'UTC',
);

Anti-patterns

The closure must be fast and side-effect free — it runs on every read.

Lifecycle

flowchart LR
    A[Closure] -->|DateTimeImmutable| B[CallbackClock]
    B --> C[ClockInterface consumers]

Feature comparison with competitors

Aspect🏆 CloudCastlesymfonycarbonlcobuccibesteergebnis
Arbitrary moment source✅❌❌❌❌❌
Declared timezone✅❌❌❌❌❌
Full package clock contract✅❌❌❌❌❌
Closure instead of inheritance✅❌❌❌❌❌
Total🏆 400000

← Back to the feature list


🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano