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 )
コード例 #1
0
ファイル: TimeUnitFormat.php プロジェクト: dantleech/phpbench
 /**
  * {@inheritdoc}
  */
 public function format($subject, array $options)
 {
     return $this->timeUnit->format($subject, in_array('unit', $options['resolve']) ? $this->timeUnit->resolveDestUnit($options['unit']) : $options['unit'], in_array('mode', $options['resolve']) ? $this->timeUnit->resolveMode($options['mode']) : $options['mode'], $this->timeUnit->resolvePrecision($options['precision']));
 }
コード例 #2
0
ファイル: TimeUnitTest.php プロジェクト: Remo/phpbench
 /**
  * It should allow the precision to be overriden.
  */
 public function testOverridePrecision()
 {
     $unit = new TimeUnit(TimeUnit::SECONDS, TimeUnit::MINUTES, TimeUnit::MODE_THROUGHPUT, 7);
     $unit->overridePrecision(5);
     $result = $unit->format(1800, TimeUnit::HOURS, TimeUnit::MODE_TIME);
     $this->assertEquals('0.50000h', $result);
 }