navarr / periodically-advancing-clock
An implementation of PSR-20 that advances with each call
Fund package maintenance!
navarr
Installs: 128
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/navarr/periodically-advancing-clock
Requires
- php: ^8
- psr/clock: ^1
Requires (Dev)
- infection/infection: ^0.26.0
- jetbrains/phpstorm-attributes: ^1.0
- phpstan/phpstan: ^1
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.6
Provides
This package is auto-updated.
Last update: 2025-10-06 18:55:17 UTC
README
This is an implementation of PSR-20 that provides a clock that advances one defined period with each call of ->now()
Installation
composer require navarr/periodically-advancing-clock:^1
Usage
use DateInterval; use DateTimeImmutable; use Navarr\PeriodicAdvancement\AdvancingClock; // ... $date = new DateTimeImmutable('2021-02-20'); $period = new DateInterval('P1M'); $clock = new AdvancingClock(startDate: $date, period: $period); // 2021-02-20 echo $clock->now()->format('Y-m-d'); // 2021-03-20 echo $clock->now()->format('Y-m-d');