navarr / periodically-advancing-clock

An implementation of PSR-20 that advances with each call

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Periodically Advancing Clock (PSR-20)

Latest Stable Version Total Downloads Latest Unstable Version License
Tests Code Coverage Mutation score

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 SpecificTime(startDate: $date, period: $period);

// 2021-02-20
echo $clock->now()->format('Y-m-d');

// 2021-03-20
echo $clock->now()->format('Y-m-d');

About

An implementation of PSR-20 that advances with each call

License:MIT License


Languages

Language:PHP 89.0%Language:Shell 11.0%