/** * Convert amount and format it! * * @param int $amount * @param string|null $currency * @param bool $decimal * * @return string */ 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); }
/** * @param LocaleContextInterface $localeContext The locale context * @param CurrencyContextInterface $currencyContext The currency context */ public function __construct(LocaleContextInterface $localeContext, CurrencyContextInterface $currencyContext) { $this->localeContext = $localeContext; parent::__construct($this->getDefaultLocale(), $currencyContext); }