WonderPush PHP library
  • Namespace
  • Class
Navigation
  • Namespace
  • Class
Namespaces
  • WonderPush
    • Api
    • Errors
    • Net
    • Obj
    • Params
    • Util
Classes
  • ArrayUtil
  • DefaultLogger
  • JsonSerializable
  • StringUtil
  • TimeUnit
  • TimeUtil
  • TimeValue
  • UrlUtil
Interfaces
  • Logger

Class TimeValue

Time duration representation and conversion.

Namespace: WonderPush\Util
Located at Util/TimeValue.php

Methods summary

public static assertValidValue( mixed $value )

Asserts the given value is valid.

Asserts the given value is valid.

Parameters

$value
public __construct( integer|float $value, integer $unit )

Construct a new amount of time representation.

Construct a new amount of time representation.

Parameters

$value
The amount of time.
$unit
A \WonderPush\Util\TimeUnit unit constant.
public compareTo( WonderPush\Util\TimeValue $other ) : integer

Compares the object to another time value.

Compares the object to another time value.

Parameters

$other
The other time value to compare to

Returns

integer
-1, 0 or 1 respectively if the object is less, equal or greater than the given argument.
public __toString( void ) : string

Return a short human readable representation of this object, suitable for further parsing.

Return a short human readable representation of this object, suitable for further parsing.

Returns

string

See

WonderPush\Util\TimeValue::parse()
public static parse( string|integer|float|WonderPush\Util\TimeValue $value, integer $defaultUnit = TimeUnit::MILLISECONDS ) : WonderPush\Util\TimeValue|null

Parses a number with an optional unit into a time value.

Parses a number with an optional unit into a time value.

Parameters

$value
$defaultUnit
A \WonderPush\Util\TimeUnit unit constant.

Returns

WonderPush\Util\TimeValue|null
public static Nanoseconds( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of nanoseconds.

Returns a time value with the given amount of nanoseconds.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public static Microseconds( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of microseconds.

Returns a time value with the given amount of microseconds.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public static Milliseconds( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of milliseconds.

Returns a time value with the given amount of milliseconds.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public static Seconds( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of seconds.

Returns a time value with the given amount of seconds.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public static Minutes( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of minutes.

Returns a time value with the given amount of minutes.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public static Hours( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of hours.

Returns a time value with the given amount of hours.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public static Days( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of days.

Returns a time value with the given amount of days.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public static Weeks( integer|float $value ) : WonderPush\Util\TimeValue

Returns a time value with the given amount of weeks.

Returns a time value with the given amount of weeks.

Parameters

$value

Returns

WonderPush\Util\TimeValue
public convert( integer $toUnit ) : WonderPush\Util\TimeValue

Converts the time value into another time value using the desired unit.

Converts the time value into another time value using the desired unit.

Parameters

$toUnit
A \WonderPush\Util\TimeUnit unit constant.

Returns

WonderPush\Util\TimeValue
public to( integer $toUnit ) : integer|float

Returns the time value amount expressed in the desired unit.

Returns the time value amount expressed in the desired unit.

Parameters

$toUnit
A \WonderPush\Util\TimeUnit unit constant.

Returns

integer|float
public toNanoseconds( void ) : integer|float

Returns the time value amount expressed in nanoseconds.

Returns the time value amount expressed in nanoseconds.

Returns

integer|float
public toMicroseconds( void ) : integer|float

Returns the time value amount expressed in microseconds.

Returns the time value amount expressed in microseconds.

Returns

integer|float
public toMilliseconds( void ) : integer|float

Returns the time value amount expressed in milliseconds.

Returns the time value amount expressed in milliseconds.

Returns

integer|float
public toSeconds( void ) : integer|float

Returns the time value amount expressed in seconds.

Returns the time value amount expressed in seconds.

Returns

integer|float
public toMinutes( void ) : integer|float

Returns the time value amount expressed in minutes.

Returns the time value amount expressed in minutes.

Returns

integer|float
public toHours( void ) : integer|float

Returns the time value amount expressed in hours.

Returns the time value amount expressed in hours.

Returns

integer|float
public toDays( void ) : integer|float

Returns the time value amount expressed in days.

Returns the time value amount expressed in days.

Returns

integer|float
public toWeeks( void ) : integer|float

Returns the time value amount expressed in weeks.

Returns the time value amount expressed in weeks.

Returns

integer|float
public getHumanUnit( void ) : integer

Returns the most appropriate time unit to express the time value.

Returns the most appropriate time unit to express the time value.

Returns

integer
A \WonderPush\Util\TimeUnit unit constant.
public toHumanUnit( array $options = array() ) : string

Formats the time value into a human readable representation, suitable for parsing.

Formats the time value into a human readable representation, suitable for parsing.

Parameters

$options

Available keys:

  • short (boolean, default false): Use a 1-2 letter unit
  • round (boolean, default false): Round to the nearest integer.

Returns

string

Properties summary

public $value : integer|float

The amount of time.

The amount of time.


		
public $unit : integer

The unit the amount of time is expressed into.

The unit the amount of time is expressed into.

See

WonderPush\Util\TimeUnit

		
WonderPush PHP library API documentation generated by ApiGen