private function getLocale(string $locale = null) : string
 {
     if (null === $locale) {
         if (null === $this->forcedLocale) {
             return $this->requestHelper->getCurrentLocale();
         } else {
             return $this->forcedLocale;
         }
     }
     return $locale;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function format($amount, $currency = null, $locale = null)
 {
     if (null === $currency) {
         $currency = $this->requestHelper->getCurrentCurrency();
     }
     if (null === $locale) {
         $locale = $this->requestHelper->getCurrentLocale();
     }
     $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
     if (false === ($result = $formatter->formatCurrency($amount, $currency))) {
         throw new CurrencyFormatterException($amount, $currency, $locale);
     }
     return $result;
 }