bag2/clock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bag2/clock

最新稳定版本:v1.0.0

Composer 安装命令:

composer require bag2/clock

包简介

README 文档

README

A PSR-20 Clock implementation.

Interface

This is the only method provided by the PSR-20 Clock interface.

<?php

namespace Psr\Clock;

interface ClockInterface
{
    /**
     * Returns the current time as a DateTimeImmutable Object
     */
    public function now(): \DateTimeImmutable;

}

Interoperability with DateTime Libraries

Today, Carbon and Chronos are known as useful libraries that extend the DateTime class.

Both provide classes that extend from DateTimeImmutable, so it's easy to get an adapter.

If the PSR defines the Clock interface, it is convenient for these adapters to be shipped with their respective libraries for the user.

DateTime for Testing

Writing tests for time-dependent functions is hard. Clock Interface is one of the solutions for that.

However, this requires the application to remove the new DateTime() (no arguments) and the time functions (date(), time(), strtotime()).

Other options are php-timecop, Chronos::setTestNow(), Carbon::setTestNow() and rashidlaasri/travel. However, they are not object-oriented as they depend on global state (or static properties).

Testing helper classes

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固