Skip to content

JD297/psr-clock

Repository files navigation

psr-clock (PSR-20)

Simple implementation of PSR-20 (Clock).

Requirements

The following versions of PHP are supported by this version.

  • PHP ^8.1

Usage

All clocks are implementing the Psr\Clock\ClockInterface.

SystemClock

The SystemClock just gives the current time according to your system.

use Jd297\Psr\Clock\SystemClock;

$clock = new SystemClock();

$unixTimestamp = $clock->now()->getTimestamp();

StaticClock

The StaticClock is suitable for mocking your application.

use Jd297\Psr\Clock\StaticClock;

$clock = new StaticClock('2001-09-09 01:46:40.000000');

$unixTimestamp = $clock->now()->getTimestamp(); // 1000000000

Composer

Scripts

Reformat code with PHP CS Fixer.

$ composer reformat

Test source code with PHPUnit.

$ composer unit

Analyse files with PHPStan (Level 9).

$ composer analyse

License

The BSD 2-Clause "Simplified" License (BSD-2-Clause). Please see License File for more information.