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)); }
/** * @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; }