public function assertSameCurrency(MoneyInterface $rightHandValue) { if (!$this->isSameCurrency($rightHandValue)) { $msg = "Different currencies provided: Money object of Currency type %s with precision %n and display precision %n expected."; throw new InvalidArgumentException(sprintf($msg, $this->currency->getCurrencyCode(), $this->currency->getPrecision(), $this->currency->getDisplayPrecision())); } }
/** * {inheritDoc} */ public function equals(CurrencyInterface $currency) { return $this->currencyCode === $currency->getCurrencyCode() && $this->precision === $currency->getPrecision() && $this->displayPrecision === $currency->getDisplayPrecision(); }
/** * Compares currency codes as plain strings, ignoring precision * * @param \Matmar10\Money\Entity\CurrencyInterface $currency The currency pair to check against * @param \Matmar10\Money\Entity\CurrencyInterface $compareToCurrency The currency pair to check against * @return boolean */ static function currencyCodesMatch(CurrencyInterface $currency, CurrencyInterface $compareToCurrency) { return $currency->getCurrencyCode() === $compareToCurrency->getCurrencyCode(); }