manchenkov/timer

'Timer' is a class to help build time interval value in seconds by object-oriented style

1.0.3 2020-10-07 21:29 UTC

This package is auto-updated.

Last update: 2024-11-19 12:13:57 UTC


README

Latest Stable Version Total Downloads License PHP Version Require

Timer is a class to help build time interval value in seconds by object-oriented style

Installation

You have to run following command to add a dependency to your project

composer require manchenkov/timer

or you can add this line to require section of composer.json

"manchenkov/timer": "*"

Usage

use Manchenkov\Timer\Timer;

$timer = Timer::get()->hours(5)->minutes(10)->seconds(34);

$intervalValue = $timer->asNumber(); // <int> -> 18634 = 34 + (10 * 60) + (5 * 3600)

$intervalString = $timer->asString(); // <string> -> 05:10:34
// or
$intervalString = (string)$timer; // <string> -> 05:10:34

Testing

To run test cases you should execute the following command

./vendor/bin/phpunit tests --testdox