GithubHelp home page GithubHelp logo

clock-5's Introduction

[WIP] PSR Clock

Work in Progress!

This repository holds the interface for PSR-20.

Note that this is not a clock of its own. It is merely an interface that describes a clock. See the specification for more details.

CAVEAT: This is currently Work in Progress!

Do not (I repeat: Do NOT) rely on this interface being stable!

Using this as long as the PSR is not officially released happens at your own risk!

Installation

composer require psr/clock

Usage

If you need a clock, you can use the interface like this:

<?php

use Psr\Clock\ClockInterface;

class Foo
{
    private ClockInterface $clock;

    public function __construct(ClockInterface $clock)
    {
        $this->clock = $clock;
    }

    public function doSomething()
    {
        /** @var DateTimeImmutable $currentDateAndTime */
        $currentDateAndTime = $this->clock->now();
        // do something useful with that information
    }
}

You can then pick one of the implementations of the interface to get a clock.

If you want to implement the interface, you can require this package and implement Psr\Clock\ClockInterface in your code.

Don't forget to add psr/clock-implementation to your composer.jsons provides-section like this:

{
  "provides": {
    "psr/clock-implementation": "1.0"
  }
}

And please read the specification text for details on the interface.

clock-5's People

Contributors

cseufert avatar gromnan avatar heiglandreas avatar localheinz avatar simivar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.