Example #1
0
 /**
  * {@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);
 }
Example #2
0
 /**
  * {@inheritDoc}
  *
  * @todo
  */
 public function exchange(Money $money, $targetCurrency)
 {
     if (is_string($targetCurrency)) {
         $targetCurrency = Currency::create($targetCurrency);
     }
     $exchangeRate = 0;
     return $money->exchange($targetCurrency, $exchangeRate);
 }
Example #3
0
 /**
  * Format a number
  *
  * @param  Money  $money
  * @param  string $locale
  * @param  bool   $showDecimals
  * @param  string $pattern
  * @return string
  */
 protected function render(Money $money, $locale, $showDecimals, $pattern)
 {
     $currencyFormatter = $this->getCurrencyFormatter();
     return $currencyFormatter((string) $money->getAmount(), (string) $money->getCurrency(), $showDecimals, $locale, $pattern);
 }