/**
  * Check if currency definitions exist in dictionary
  *
  * @param Currency $currency
  *
  * @throws InvalidArgumentException
  */
 private function guardAgainstUnexistingCurrency(Currency $currency)
 {
     if (!array_key_exists($currency->getIdentifier(), $this->currencyDictionary->getUnitNames())) {
         throw new InvalidArgumentException(sprintf('There is missing "%s" unit in a currency dictionary', $currency->getIdentifier()));
     }
     if (!array_key_exists($currency->getIdentifier(), $this->currencyDictionary->getSubunitNames())) {
         throw new InvalidArgumentException(sprintf('There is missing "%s" subunit in a currency dictionary', $currency->getIdentifier()));
     }
 }
예제 #2
0
 /**
  * Gets a single subunit name for the provided currency
  *
  * @param CurrencyModel $currency
  * @param bool $singular
  *
  * @return string
  */
 public function getSubunitName(CurrencyModel $currency, $plural)
 {
     $subunit = $this->subunitNames[$currency->getIdentifier()];
     return $subunit[$plural ? 'plural' : 'singular'];
 }