/** * {@inheritDoc} * * @throws Exception\InvalidArgumentException If $money's currency is not equal to the currency to exchange from */ public function exchange(Money $money, $roundingMode = Money::ROUND_HALF_UP) { if ($money->getCurrency() != $this->getFromCurrency()) { throw new Exception\InvalidArgumentException('The Money has the wrong currency'); } return $money->exchange($this->getToCurrency(), $this->getExchangeRate(), $roundingMode); }
/** * {@inheritDoc} * * @todo */ public function exchange(Money $money, $targetCurrency) { if (is_string($targetCurrency)) { $targetCurrency = Currency::create($targetCurrency); } $exchangeRate = 0; return $money->exchange($targetCurrency, $exchangeRate); }