PhpBench\Util\TimeUnit::format PHP Method

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 )
    public function format($time, $unit = null, $mode = null, $precision = null, $suffix = true)
    {
        $value = number_format($this->toDestUnit($time, $unit, $mode), $precision !== null ? $precision : $this->precision);
        if (false === $suffix) {
            return $value;
        }
        $suffix = $this->getDestSuffix($unit, $mode);
        return $value . $suffix;
    }

Usage Example

Example #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']));
 }
All Usage Examples Of PhpBench\Util\TimeUnit::format