PHP Class PhpBench\Util\TimeUnit

Show file Open project: dantleech/phpbench Class Usage Examples

Public Methods

Method Description
__construct ( $sourceUnit = self::MICROSECONDS, $destUnit = self::MICROSECONDS, $mode = self::MODE_TIME, $precision = 3 )
convert ( integer $time, string $unit, string $destUnit, string $mode ) : integer Convert given time in given unit to given destination unit in given mode.
convertInto ( $time, $unit, $destUnit ) : integer Convert a given time INTO the given unit. That is, how many times the given time will fit into the the destination unit. i.e. x per unit.
convertTo ( $time, $unit, $destUnit ) : integer Convert the given time from the given unit to the given destination unit.
format ( $time, $unit = null, $mode = null, $precision = null, $suffix = true ) Return a human readable representation of the unit including the suffix.
getDestSuffix ( string $unit = null, $mode = null ) : string Return the destination unit suffix.
getDestUnit ( string $unit = null ) : string Return the destination unit.
getMode ( $mode = null ) : string Return the destination mode.
getSuffix ( $unit, $mode = null ) : string Return the suffix for a given unit.
overrideDestUnit ( $destUnit ) Override the destination unit.
overrideMode ( string $mode ) Override the mode.
overridePrecision ( integer $precision ) Override the precision.
resolveDestUnit ( $unit ) : string Utility method, if the dest unit is overridden, return the overridden value.
resolveMode ( $mode ) : string Utility method, if the mode is overridden, return the overridden value.
resolvePrecision ( $precision ) : string Utility method, if the precision is overridden, return the overridden value.
toDestUnit ( $time, $destUnit = null, $mode = null ) : integer Convert instance value to given unit.

Private Methods

Method Description
validateMode ( $mode )
validateUnit ( $unit )

Method Details

__construct() public method

public __construct ( $sourceUnit = self::MICROSECONDS, $destUnit = self::MICROSECONDS, $mode = self::MODE_TIME, $precision = 3 )

convert() public static method

Convert given time in given unit to given destination unit in given mode.
public static convert ( integer $time, string $unit, string $destUnit, string $mode ) : integer
$time integer
$unit string
$destUnit string
$mode string
return integer

convertInto() public static method

Convert a given time INTO the given unit. That is, how many times the given time will fit into the the destination unit. i.e. x per unit.
public static convertInto ( $time, $unit, $destUnit ) : integer
return integer

convertTo() public static method

Convert the given time from the given unit to the given destination unit.
public static convertTo ( $time, $unit, $destUnit ) : integer
return integer

format() public method

Return a human readable representation of the unit including the suffix.
public format ( $time, $unit = null, $mode = null, $precision = null, $suffix = true )

getDestSuffix() public method

Return the destination unit suffix.
public getDestSuffix ( string $unit = null, $mode = null ) : string
$unit string
return string

getDestUnit() public method

Return the destination unit.
public getDestUnit ( string $unit = null ) : string
$unit string
return string

getMode() public method

Return the destination mode.
public getMode ( $mode = null ) : string
return string

getSuffix() public static method

Return the suffix for a given unit.
public static getSuffix ( $unit, $mode = null ) : string
return string

overrideDestUnit() public method

Override the destination unit.
public overrideDestUnit ( $destUnit )

overrideMode() public method

Override the mode.
public overrideMode ( string $mode )
$mode string

overridePrecision() public method

Override the precision.
public overridePrecision ( integer $precision )
$precision integer

resolveDestUnit() public method

Utility method, if the dest unit is overridden, return the overridden value.
public resolveDestUnit ( $unit ) : string
return string

resolveMode() public method

Utility method, if the mode is overridden, return the overridden value.
public resolveMode ( $mode ) : string
return string

resolvePrecision() public method

Utility method, if the precision is overridden, return the overridden value.
public resolvePrecision ( $precision ) : string
return string

toDestUnit() public method

Convert instance value to given unit.
public toDestUnit ( $time, $destUnit = null, $mode = null ) : integer
return integer