承接 eventsauce/clock 相关项目开发

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

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

eventsauce/clock

最新稳定版本:1.2.2

Composer 安装命令:

composer require eventsauce/clock

包简介

Consume time from a Clock

README 文档

README

This is the EventSauce Clock component, which provides a straight forward way to consume time. Using a clock makes your code easier to test.

Installation

composer require eventsauce/clock

Usage

This package provides two implementations of the EventSauce\Clock\Clock interface.

In your production configuration, use the EventSauce\Clock\SystemClock implementation.

<?php

use EventSauce\Clock\SystemClock;

$clock = new SystemClock(new DateTimeZone('UTC') /* timezone optional */);

$dateTimeImmutable = $clock->now();
$timezone = $clock->timeZone();

In your test configuration, use the EventSauce\Clock\TestClock implementation.

<?php

use EventSauce\Clock\TestClock;

$testClock = new TestClock();
$dateTimeImmutable = $testClock->now();
$timezone = $testClock->timeZone();

// move the clock forward
$testClock->moveForward(DateInterval::createFromDateString('1 day'));

// Skip to system "now"
$testClock->tick();

// Fixate the clock to a specific date and time
$testClock->fixate('1987-11-24 18:33:10');

统计信息

  • 总下载量: 1.45M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-27