FrozenClock: add advance() method for relative time shifting #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
FrozenClock::set()requires an absoluteDateTimeImmutable, which forces tests to compute the target timestamp manually. Advancing by "1 hour" or "30 seconds" relative to the current frozen time is unnecessarily verbose.Proposed API
advance()adds the given interval to the currently frozen time and updates the internal state — equivalent to callingset($clock->now()->add($interval)).Benefits
set()callsDateTimeImmutable::add()worksAcceptance criteria
advance(string|\DateInterval $interval): voidnew \DateInterval()DateIntervalvariants