arth / time-machine
Abstraction for current datetime
Installs: 143
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/arth/time-machine
Requires (Dev)
- phpunit/php-code-coverage: ^6.0.7
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2025-09-29 02:42:09 UTC
README
Module for application time control for testing purpose.
Usage:
composer req arth/time-machine
- replace all
new DateTime('now')
and analogues withArth\Utils\TimeMachine::getInstance()->getNow()
- in tests call
Arth\Utils\TimeMachine::getInstance()->setNow($dt)
with necessary $dt object for time shift.
Changelog
v1.0.0
- getNow()/setNow(DateTimeInterface)
- setFreezedMode(bool) - is time tick between getNow() calls?
- date2ts(DateTimeInterface)/ts2date($ts) with correct microseconds handling