src/ISOCurrencyProvider.php
public function getCurrencyForCountry(string $countryCode) : Currency
    {
        $currencies = $this->getCurrenciesForCountry($countryCode);

        $count = count($currencies);

        if ($count === 1) {
            return $currencies[0];
        }

        if ($count === 0) {
            throw UnknownCurrencyException::noCurrencyForCountry($countryCode);
        }

        $currencyCodes = [];

        foreach ($currencies as $currency) {
            $currencyCodes[] = $currency->getCurrencyCode();
        }

        throw UnknownCurrencyException::noSingleCurrencyForCountry($countryCode, $currencyCodes);
    }
public function getCurrencyForCountry(string $countryCode) : Currency
    {
        $currencies = $this->getCurrenciesForCountry($countryCode);

        $count = count($currencies);

        if ($count === 1) {
            return $currencies[0];
        }

        if ($count === 0) {
            throw UnknownCurrencyException::noCurrencyForCountry($countryCode);
        }

        $currencyCodes = [];

        foreach ($currencies as $currency) {
            $currencyCodes[] = $currency->getCurrencyCode();
        }

        throw UnknownCurrencyException::noSingleCurrencyForCountry($countryCode, $currencyCodes);
    }
public function getCurrencyForCountry ( string $ countryCode ) : Currency { $ currencies = $ this -> getCurrenciesForCountry ( $ countryCode ) ; $ count = count ( $ currencies ) ; if ( $ count === 1 ) { return $ currencies [ 0 ] ; } if ( $ count === 0 ) { throw UnknownCurrencyException :: noCurrencyForCountry ( $ countryCode ) ; } $ currencyCodes = [ ] ; foreach ( $ currencies as $ currency ) { $ currencyCodes [ ] = $ currency -> getCurrencyCode ( ) ; } throw UnknownCurrencyException :: noSingleCurrencyForCountry ( $ countryCode , $ currencyCodes ) ; }
Returns the currency for the given ISO country code.

@param string $countryCode The 2-letter ISO 3166-1 country code.

@return Currency

@throws UnknownCurrencyException If the country code is not known, or the country has no single currency.
Returns the currency for the given ISO country code .