예제 #1
0
 /**
  * @param Money    $money
  * @param Currency $currency
  *
  * @return Money
  *
  * @throws CurrencyConversionException If the exchange rate is not available.
  * @throws RoundingNecessaryException  If rounding was necessary but this converter uses RoundingMode::UNNECESSARY.
  */
 public function convert(Money $money, Currency $currency)
 {
     if ($money->getCurrency()->is($currency)) {
         $exchangeRate = 1;
     } else {
         $exchangeRate = $this->exchangeRateProvider->getExchangeRate($money->getCurrency()->getCode(), $currency->getCode());
     }
     return $money->convertedTo($currency, $exchangeRate, $this->context);
 }