Пример #1
0
 public function convertToUSD(Money $money, ExchangeRate $exchangeRate)
 {
     if ($exchangeRate->getCurrency() != $money->getCurrency()) {
         throw new InvalidCurrencyExchangeException();
     }
     $rate = $exchangeRate->getRate();
     $amountInUSD = $money->divide($rate);
     return Money::create($amountInUSD->getAmount(), Currency::CODE_USD);
 }