Esempio n. 1
0
 /**
  * @param  CurrencyCodeFormatter $currencyCodeFormatter
  * @return array
  */
 protected static function getCurrencyValueOptions(CurrencyCodeFormatter $currencyCodeFormatter)
 {
     $commonCurrencies = [];
     $remainingCurrencies = [];
     foreach (static::$commonCurrencyCodes as $currencyCode) {
         $commonCurrencies[$currencyCode] = $currencyCodeFormatter->format($currencyCode);
     }
     foreach (static::$remainingCurrencyCodes as $currencyCode) {
         $remainingCurrencies[$currencyCode] = $currencyCodeFormatter->format($currencyCode);
     }
     $collator = new Collator(Locale::getDefault());
     $collator->asort($remainingCurrencies);
     return [['label' => 'Common currencies', 'options' => $commonCurrencies], ['label' => 'Remamining Currencies', 'options' => $remainingCurrencies]];
 }
 /**
  * @covers ::format
  */
 public function testFormatThrowsExceptionOnInvalidCurrencyCode()
 {
     $this->setExpectedException('UnexpectedValueException', 'Invalid currency code provided: "foobar"');
     $formatter = new CurrencyCodeFormatter('en-US');
     $formatter->format('foobar');
 }
Esempio n. 3
0
 /**
  * @param  string $currencyCode
  * @return string
  */
 public function __invoke($currencyCode)
 {
     return $this->currencyCodeFormatter->format($currencyCode);
 }