public static function format($value, $to, $from = null)
    {
        if ($to instanceof Measure === false) {
            throw new Exception('Unknown object');
        }
        if ($from instanceof Measure) {
            $value = static::convert($value, $to, $from);
        }
        $formatter = $to->use_custom_formatter == true ? $to->formatter : \Yii::$app->formatter;
        return strtr(
            $to->format,
            [
                '#' => $formatter->asDecimal($value),
                '$' => static::t($to->unit),
            ]
        );
    }
public static function format($value, $to, $from = null)
    {
        if ($to instanceof Measure === false) {
            throw new Exception('Unknown object');
        }
        if ($from instanceof Measure) {
            $value = static::convert($value, $to, $from);
        }
        $formatter = $to->use_custom_formatter == true ? $to->formatter : \Yii::$app->formatter;
        return strtr(
            $to->format,
            [
                '#' => $formatter->asDecimal($value),
                '$' => static::t($to->unit),
            ]
        );
    }
public static function format ( $ value , $ to , $ from = null ) { if ( $ to instanceof Measure === false ) { throw new Exception ( 'Unknown object' ) ; } if ( $ from instanceof Measure ) { $ value = static :: convert ( $ value , $ to , $ from ) ; } $ formatter = $ to -> use_custom_formatter == true ? $ to -> formatter : \ Yii :: $ app -> formatter ; return strtr ( $ to -> format , [ '#' => $ formatter -> asDecimal ( $ value ) , '$' => static :: t ( $ to -> unit ) , ] ) ; }
Format a value by rule as a string
@param double $value
@param Measure $to
@param Measure|null $from
@return string
@throws Exception
Format a value by rule as a string