Exemple #1
0
 /**
  * @dataProvider validStrings
  */
 public function testCorrectlyParsesStrings($number, $value, $scale, $string)
 {
     $number = new Decimal($number);
     $this->assertEquals($value, $number->value());
     $this->assertEquals($scale, $number->scale());
     $this->assertEquals($string, (string) $number);
 }
Exemple #2
0
 /**
  * maxScale
  *
  * @param Decimal $other
  *
  * @return mixed
  */
 private function maxScale(Decimal $other)
 {
     return max($this->scale, $other->scale());
 }
Exemple #3
0
 /**
  * Creates a new instance from an existing instance.
  *
  * Note that if the scale is not specified the original instance will be returned since it represents the same
  * value.
  *
  * @param Decimal  $decimal
  * @param int|null $scale
  *
  * @return Decimal
  */
 public static function fromDecimal(Decimal $decimal, int $scale = null) : Decimal
 {
     if (null === $scale) {
         return $decimal;
     }
     return $decimal->scale($scale);
 }