コード例 #1
0
 public function testLocalization()
 {
     $localizer = $this->getMock('ValueFormatters\\NumberLocalizer');
     $localizer->expects($this->once())->method('localizeNumber')->will($this->returnCallback(function ($number) {
         return "n:{$number}";
     }));
     $value = new DecimalValue('+12345');
     $formatter = new DecimalFormatter(null, $localizer);
     $this->assertEquals('n:12345', $formatter->format($value));
 }
コード例 #2
0
ファイル: QuantityFormatter.php プロジェクト: gmelikov/Number
 /**
  * @param DecimalValue $margin
  * @param int $roundingExponent
  *
  * @return string|null Text
  */
 private function formatMargin(DecimalValue $margin, $roundingExponent)
 {
     if ($this->options->getOption(self::OPT_SHOW_UNCERTAINTY_MARGIN)) {
         // TODO: never round to 0! See bug #56892
         $roundedMargin = $this->decimalMath->roundToExponent($margin, $roundingExponent);
         if (!$roundedMargin->isZero()) {
             return $this->decimalFormatter->format($roundedMargin);
         }
     }
     return null;
 }