Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function convertAndFormatAmount($amount, $currencyCode = null, $locale = null)
 {
     if (null !== $currencyCode) {
         $amount = $this->currencyConverter->convertFromBase($amount, $currencyCode);
     }
     return $this->moneyHelper->formatAmount($amount, $currencyCode, $locale);
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function convertAndFormatAmount($amount, $currencyCode = null, $exchangeRate = null, $locale = null)
 {
     if (null !== $currencyCode && $exchangeRate !== null) {
         $amount = (int) round($amount * $exchangeRate);
     }
     if (null !== $currencyCode && $exchangeRate === null) {
         $amount = $this->currencyConverter->convertFromBase($amount, $currencyCode);
     }
     return $this->moneyHelper->formatAmount($amount, $currencyCode, $locale);
 }
Beispiel #3
0
 function it_converts_money_using_given_currency_and_locale(CurrencyConverterInterface $currencyConverter, MoneyHelperInterface $moneyHelper)
 {
     $currencyConverter->convertFromBase(500, 'USD')->willReturn(250);
     $moneyHelper->formatAmount(250, 'USD', 'fr_FR')->willReturn('$2.50');
     $this->convertAndFormatAmount(500, 'USD', 'fr_FR')->shouldReturn('$2.50');
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function formatAmount($amount, $currencyCode = null, $locale = null)
 {
     $locale = $locale ?: $this->localeContext->getLocaleCode();
     return $this->decoratedHelper->formatAmount($amount, $currencyCode, $locale);
 }
Beispiel #5
0
 /**
  * Format the money amount to nice display form.
  *
  * @param int     $amount
  * @param string|null $currency
  *
  * @return string
  */
 public function formatAmount($amount, $currency = null, $locale = null)
 {
     return $this->helper->formatAmount($amount, $currency, false, $locale);
 }
Beispiel #6
0
 function it_decorates_the_helper_with_current_locale_if_it_is_not_passed(MoneyHelperInterface $decoratedHelper, LocaleContextInterface $localeContext)
 {
     $localeContext->getLocaleCode()->willReturn('fr_FR');
     $decoratedHelper->formatAmount(42, null, 'fr_FR')->willReturn('Formatted 42 in fr_FR');
     $this->formatAmount(42)->shouldReturn('Formatted 42 in fr_FR');
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 public function convertAndFormatAmount($amount, $currency = null, $decimal = false)
 {
     $currency = $currency ?: $this->currencyContext->getCurrency();
     $amount = $this->converter->convertFromBase($amount, $currency);
     return $this->moneyHelper->formatAmount($amount, $currency, $decimal);
 }
 function it_converts_money_using_given_currency_and_exchange_rate(CurrencyConverterInterface $currencyConverter, MoneyHelperInterface $moneyHelper)
 {
     $currencyConverter->convertFromBase(Argument::cetera())->shouldNotBeCalled();
     $moneyHelper->formatAmount(300, 'GBP', null)->willReturn('£3.00');
     $this->convertAndFormatAmount(100, 'GBP', 3.0)->shouldReturn('£3.00');
 }