PSR-20 clocks, and the fake I stopped writing

A clock interface written by hand in four projects, each slightly different, replaced by the standard one.

use PsrClockClockInterface;

final class BillingCycle
{
    public function __construct(private ClockInterface $clock) {}

    public function isDue(Subscription $s): bool
    {
        return $s->nextChargeAt <= $this->clock->now();
    }
}

// and the fake, which now comes from a package rather
// than being written again:
$clock = new MockClock('2024-04-03 09:00:00');

One method returning a DateTimeImmutable is a small enough interface that writing it again feels cheaper than adding a dependency, and the cost of four slightly different versions is that no fake works across them. Standardising also meant a library we use could accept our clock, which is the actual point of a PSR and the part that never applies to a hand-rolled one.