承接 tobento/service-clock 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tobento/service-clock

最新稳定版本:2.0

Composer 安装命令:

composer require tobento/service-clock

包简介

PSR-20 clocks for PHP applications.

README 文档

README

Providing PSR-20 clocks for PHP applications.

Table of Contents

Getting started

Add the latest version of the clock service project running this command.

composer require tobento/service-clock

Requirements

  • PHP 8.4 or greater

Highlights

  • Framework-agnostic, will work with any project
  • Decoupled design

Documentation

Available Clocks

System Clock

The system clock relies on the current system time. If the timezone parameter is not defined it uses the timezone from the date_default_timezone_get method.

use Tobento\Service\Clock\SystemClock;
use Psr\Clock\ClockInterface;

$clock = new SystemClock();

var_dump($clock instanceof ClockInterface);
// bool(true)

With defined timezone parameter

use Tobento\Service\Clock\SystemClock;
use DateTimeZone;

$clock = new SystemClock(
    timezone: 'UTC'
);

$clock = new SystemClock(
    timezone: new DateTimeZone('Europe/Berlin')
);

Frozen Clock

The frozen clock will always return the same date time, suitable for testing. If the now parameter is not defined it uses the current time of the System Clock.

use Tobento\Service\Clock\FrozenClock;
use Psr\Clock\ClockInterface;

$clock = new FrozenClock();

var_dump($clock instanceof ClockInterface);
// bool(true)

// Modify the clock returning a new instance.
// Will accept all formats supported by DateTimeImmutable::modify()
$clockNew = $clock->modify('+30 seconds');

// With a new timezone returning a new instance.
$clockNew = $clock->withTimeZone(timezone: 'UTC');

With defined now parameter

use Tobento\Service\Clock\FrozenClock;
use Tobento\Service\Clock\SystemClock;
use Psr\Clock\ClockInterface;
use DateTimeImmutable;

$clock = new FrozenClock(
    now: new DateTimeImmutable()
);

// or from another clock:
$clock = new FrozenClock(
    now: new SystemClock()
);

Credits

统计信息

  • 总下载量: 260
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 8
  • 推荐数: 2

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固