format() публичный Метод

Return a human readable representation of the unit including the suffix.
public format ( $time, $unit = null, $mode = null, $precision = null, $suffix = true )
Пример #1
0
 /**
  * {@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
 /**
  * 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);
 }