/** * 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(); }
/** * {@inheritDoc} */ public function equals(CurrencyInterface $currency) { return $this->toArray() == $currency->toArray(); }