PhpBench\Util\TimeUnit::convertTo PHP Method

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
    public static function convertTo($time, $unit, $destUnit)
    {
        self::validateUnit($unit);
        self::validateUnit($destUnit);
        $destM = self::$map[$destUnit];
        $sourceM = self::$map[$unit];
        $time = $time * $sourceM / $destM;
        return $time;
    }

Usage Example

Example #1
0
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Expected string value
  */
 public function testInvalidUnitType()
 {
     TimeUnit::convertTo(100, new \stdClass(), TimeUnit::MINUTES);
 }