php-cooper

CooperDuration
in package
implements Stringable

FinalYes

A CASC duration (CASC.md ยง6.8) -- `500ms`, `1h30m`, or `!duration("5m")` -- as a whole number of nanoseconds, the same base unit the Elixir original's `{:duration, nanoseconds}` uses.

The count follows the integer rule (CooperInteger): a native int when it fits in 64 bits, a CooperInteger beyond. It was once a plain int, and 300000000d -- about 820 000 years, which the reference loads without complaint -- was a load error here.

Table of Contents

Interfaces

Stringable

Properties

$nanoseconds  : int|CooperInteger
The duration's total length in nanoseconds.

Methods

__construct()  : mixed
__toString()  : string
The duration in its base unit -- `"500000000ns"` -- which is also valid CASC if fed back in.
equals()  : bool
toMicroseconds()  : int|CooperInteger
toMilliseconds()  : int|CooperInteger
toSeconds()  : float
divided()  : int|CooperInteger
`$count` divided by `$divisor`, truncated toward zero.

Properties

Methods

__construct()

public __construct(int|CooperInteger $nanoseconds) : mixed
Parameters
$nanoseconds : int|CooperInteger

the duration's total length in nanoseconds; a CooperInteger that fits is kept as an int

__toString()

The duration in its base unit -- `"500000000ns"` -- which is also valid CASC if fed back in.

public __toString() : string
Return values
string —

the nanosecond count with an ns suffix

equals()

public equals(mixed $other) : bool
Parameters
$other : mixed

the value to compare against

Return values
bool —

true for a duration of the same length

toSeconds()

public toSeconds() : float
Return values
float —

the duration in (fractional) seconds -- the nearest float, for a count beyond 64 bits

On this page

Search results