jd297/psr-clock

Simple implementation of PSR-20 (Clock)

1.0.0 2024-02-05 21:21 UTC

This package is auto-updated.

Last update: 2024-04-05 22:03:28 UTC


README

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.