arnapou/psr-clock

Library - PSR-20.

v1.1.1 2024-11-25 07:33 UTC

This package is auto-updated.

Last update: 2024-11-25 06:46:00 UTC


README

pipeline coverage

KISS (Keep It Simple Stupid) PSR (PHP Standards Recommendations) classes.

Installation

composer require arnapou/psr-clock

packagist 👉️ arnapou/psr-clock

When it is worth to use this library

  • you need simple decorators, proxies, adapters, ... about PSR's
  • you need simple implementations covering the basics

Example PSR-20 Clock Interface

One of the most simple PSR, but very powerful.

This repo uses this clock interface in loggers and caches.

It helps a lot for testing for example.

// Basic clock with date and timezone
$clock = new \Arnapou\Psr\Psr20Clock\NowClock();
echo $clock->now()->format('Y-m-d H:i:s') . "\n";

// This clock will always have the same "time".
$clock = \Arnapou\Psr\Psr20Clock\FixedClock::createFromTimestamp(time());
echo $clock->now()->format('Y-m-d H:i:s') . "\n";

Php versions

DateRef8.48.38.2
24/11/20241.1.x, main×××
09/09/20241.0.x××