Integration
FastForward Clock is designed to work seamlessly with Fast Forward Container.
The expected integration flow is:
- register
ClockServiceProviderin the composition root; - use
SystemClockin production andFrozenClockin tests; - type-hint
Psr\Clock\ClockInterfacein application services for maximum portability.
Example
<?php
declare(strict_types=1);
use FastForward\Clock\ServiceProvider\ClockServiceProvider;
use Psr\Clock\ClockInterface;
use function FastForward\Container\container;
$container = container(new ClockServiceProvider());
$clock = $container->get(ClockInterface::class);
Why the package stays simple
This package provides two straightforward clock implementations: SystemClock
for production and FrozenClock
for testing.
Both implement the PSR-20 interface, making them compatible with any PSR-11 container or dependency injection framework.