示例#1
0
文件: Money.php 项目: coolms/money
 /**
  * Returns the value represented by this object
  *
  * @return Decimal
  */
 public function toSubunits($roundingMode = self::ROUND_HALF_UP)
 {
     $this->assertRoundingMode($roundingMode);
     $precision = $this->getPrecision();
     if (null === $roundingMode) {
         $amount = $this->amount->round($precision);
     } else {
         $amount = Math::bcround($this->amount, $precision, $roundingMode);
     }
     $subunitToUnit = $this->currency->getSubunitToUnit();
     if ($subunitToUnit > 1) {
         $subunitToUnit = Decimal::create($subunitToUnit, $precision);
         $amount = $amount->mul($subunitToUnit, $precision);
     }
     return $amount->asInteger();
 }
示例#2
0
文件: Currency.php 项目: coolms/money
 /**
  * {@inheritDoc}
  */
 public function equals(CurrencyInterface $currency)
 {
     return $this->toArray() == $currency->toArray();
 }