original_string: 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),
              ]
          );
      }
code: 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),
              ]
          );
      }
code_tokens: 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 ) , ] ) ; }
docstring: Format a value by rule as a string
  @param double $value
  @param Measure $to
  @param Measure|null $from
  @return string
  @throws Exception
docstring_tokens: Format a value by rule as a string