lcobucci/clock
lcobucci/clock is a lightweight clock abstraction for PHP that decouples code from DateTimeImmutable. Use SystemClock for real time or FrozenClock for tests, making time-dependent logic easy to control and verify.
new DateTimeImmutable() calls.Clock interface and frozen test clock is technically cheap, but this package provides a PSR-20-compatible abstraction, SystemClock, FrozenClock, named constructors, and time adjustment helpers. Buying is a low-cost, MIT-licensed way to avoid custom test utilities and reinforce standards.DateTimeImmutable directly in business logic; tests use sleeps or real-time waiting; teams need PSR-20 interoperability; you maintain reusable PHP packages; or you already depend on libraries in the lcobucci ecosystem, such as JWT tooling.SystemClock, and a FrozenClock for deterministic tests. We can inject time instead of hiding it in constructors, simulate expiry and grace-period behavior, and make timezone assumptions explicit. It is framework-agnostic and fits Laravel/PHP services without forcing a larger date library.How can I help you explore Laravel packages today?