Exemplo n.º 1
0
 /**
  * @dataProvider getOrderOfUncertaintyProvider
  */
 public function testGetOrderOfUncertainty(QuantityValue $quantity, $expected)
 {
     $actual = $quantity->getOrderOfUncertainty();
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 2
0
 /**
  * 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);
     }
 }