PHP Class PhpBench\Util\TimeUnit

Afficher le fichier Open project: dantleech/phpbench Class Usage Examples

Méthodes publiques

Méthode 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

Méthode Description
validateMode ( $mode )
validateUnit ( $unit )

Method Details

__construct() public méthode

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

convert() public static méthode

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
Résultat integer

convertInto() public static méthode

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
Résultat integer

convertTo() public static méthode

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

format() public méthode

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

getDestSuffix() public méthode

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

getDestUnit() public méthode

Return the destination unit.
public getDestUnit ( string $unit = null ) : string
$unit string
Résultat string

getMode() public méthode

Return the destination mode.
public getMode ( $mode = null ) : string
Résultat string

getSuffix() public static méthode

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

overrideDestUnit() public méthode

Override the destination unit.
public overrideDestUnit ( $destUnit )

overrideMode() public méthode

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

overridePrecision() public méthode

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

resolveDestUnit() public méthode

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

resolveMode() public méthode

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

resolvePrecision() public méthode

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

toDestUnit() public méthode

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