Example #1
0
 public function testSerialize()
 {
     $value = '-1234567890987654321012345678909876543210123456789';
     $scale = 37;
     $number = BigDecimal::ofUnscaledValue($value, $scale);
     $this->assertBigDecimalInternalValues($value, $scale, unserialize(serialize($number)));
 }
Example #2
0
 /**
  * @param BigNumber|number|string $amountMinor    The integer amount in minor units.
  * @param Currency|string         $currency       The currency, as a Currency instance of currency code string.
  * @param int|null                $fractionDigits The number of fraction digits, or null to use the default.
  *
  * @return Money
  *
  * @throws UnknownCurrencyException If the currency is an unknown currency code.
  * @throws ArithmeticException      If the amount cannot be converted to a BigInteger.
  */
 public static function ofMinor($amountMinor, $currency, $fractionDigits = null)
 {
     $currency = Currency::of($currency);
     if ($fractionDigits === null) {
         $fractionDigits = $currency->getDefaultFractionDigits();
     }
     $amount = BigDecimal::ofUnscaledValue($amountMinor, $fractionDigits);
     return new Money($amount, $currency);
 }