quillstack / clock
A clock based on PSR-20: Clock, with one which stands still for tests.
v0.6.0
2026-08-21 20:53 UTC
Requires
- php: ^8.1
- psr/clock: ^1.0
Requires (Dev)
- phpstan/phpstan: ^2.0
- quillstack/unit-tests: ^0.9
This package is auto-updated.
Last update: 2026-08-23 00:22:18 UTC
README
A clock based on PSR-20: Clock, with one which stands still for tests.
Installation
composer require quillstack/clock
Usage
Anything deciding when something happened, or whether it has expired, takes a clock rather
than reading the wall clock where it stands. SystemClock is that wall clock:
use Quillstack\Clock\SystemClock; $cache = new ArrayCache(new SystemClock());
FrozenClock stands still until it is moved, so a test watches something expire without
waiting for it:
use Quillstack\Clock\FrozenClock; $clock = new FrozenClock(); $cache = new ArrayCache($clock); $cache->set('key', 'value', 60); $clock->sleep(61); $cache->get('key'); // null
It is in the sources rather than the tests, because anything taking a clock will want it.
Tests
composer test
License
MIT. See LICENSE.