/** * @dataProvider getOrderOfUncertaintyProvider */ public function testGetOrderOfUncertainty(QuantityValue $quantity, $expected) { $actual = $quantity->getOrderOfUncertainty(); $this->assertEquals($expected, $actual); }
/** * Returns the rounding exponent based on the given $quantity * and the @see QuantityFormatter::OPT_APPLY_ROUNDING option. * * @param QuantityValue $quantity * * @return int */ private function getRoundingExponent(QuantityValue $quantity) { if ($this->options->getOption(self::OPT_APPLY_ROUNDING) === true) { // round to the order of uncertainty return $quantity->getOrderOfUncertainty(); } elseif ($this->options->getOption(self::OPT_APPLY_ROUNDING) === false) { // to keep all digits, use the negative length of the fractional part return -strlen($quantity->getAmount()->getFractionalPart()); } else { return (int) $this->options->getOption(self::OPT_APPLY_ROUNDING); } }