コード例 #1
0
ファイル: ExchangeRate.php プロジェクト: coolms/money
 /**
  * {@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);
 }
コード例 #2
0
ファイル: CurrencyExchanger.php プロジェクト: coolms/money
 /**
  * {@inheritDoc}
  *
  * @todo
  */
 public function exchange(Money $money, $targetCurrency)
 {
     if (is_string($targetCurrency)) {
         $targetCurrency = Currency::create($targetCurrency);
     }
     $exchangeRate = 0;
     return $money->exchange($targetCurrency, $exchangeRate);
 }