Get a currency definition

@param string $code ISO4217 currency code

@return array ['symbol','precision', 'name']
@throws \ErrorException
976289
protected static function getDefinition($code)
    {
        $currencies = self::getDefinitions();
        $nodes = $currencies->xpath("//currency[@code='{$code}']");
        if (empty($nodes)) {
            throw new \InvalidArgumentException("Unknown currency: {$code}");
        }

        $cNode = $nodes[0];

        $def = array(
            self::createSymbol($cNode->symbol, $code),
            intval($cNode->exponent),
            self::createName($cNode),
        );

        return $def;
    }
451653
public function loadCurrenciesForCountry($code)
    {
        $currencies = $this->helper->loadJson(
            $this->helper->dataDir('currencies/default/'.strtolower($code).'.json')
        );

        return $currencies;
    }
205225
public function getCurrenciesForCountry(string $countryCode) : array
    {
        if ($this->countryToCurrency === null) {
            $this->countryToCurrency = require __DIR__ . '/../data/country-to-currency.php';
        }

        $result = [];

        if (isset($this->countryToCurrency[$countryCode])) {
            foreach ($this->countryToCurrency[$countryCode] as $currencyCode) {
                $result[] = $this->getCurrency($currencyCode);
            }
        }

        return $result;
    }
1188498
final public function get($code = null) {

        if ( is_null($code) ) return $this->rpc_errors;

        else if ( array_key_exists($code, $this->rpc_errors) ) return $this->rpc_errors[$code];

        else if ( $code >= -32099 && $code <= -32000 ) return 'Server Error';

        else return 'Unknown Error';

    }
349116
public static function getCurrencyId($isoCode)
    {
        $allCurrencies = self::getAll();

        foreach ($allCurrencies as $currency) {
            if (strcasecmp($currency['abbreviation'], $isoCode) === 0) {
                return $currency['id'];
            }
        }
        throw new NotFound('Currency', $isoCode);
    }
1114030
public static function getErrText($code)
    {
        if (isset(self::$errCode[$code])) {
            return self::$errCode[$code];
        }
        return false;
    }
1373995
public function getExceptionByCode($code)
    {
        $code       = (int) $code;
        $exceptions = array();
        foreach ($this->_exceptions as $e) {
            if ($code == $e->getCode()) {
                $exceptions[] = $e;
            }
        }

        if (empty($exceptions)) {
            $exceptions = false;
        }

        return $exceptions;
    }
571752
public function get($code)
    {
        $result = &gplcart_static("country.get.$code");

        if (isset($result)) {
            return $result;
        }

        $this->hook->attach('country.get.before', $code, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $sql = 'SELECT * FROM country WHERE code=?';
        $result = $this->db->fetch($sql, array($code), array('unserialize' => 'format'));

        if (isset($result['format'])) {
            $default_format = $this->getDefaultFormat();
            $result['format'] = gplcart_array_merge($default_format, $result['format']);
            gplcart_array_sort($result['format']);
        }

        $this->hook->attach('country.get.after', $code, $result, $this);
        return $result;
    }
366722
public function get_string_from_code($code) {
		$errors = [
			self::ERR_GENERAL => 'General Error',
			self::ERR_BAD_REQUEST => 'Bad Request',
			self::ERR_UNAUTHORIZED => 'Unauthorized',
			self::ERR_FORBIDDEN => 'Forbidden',
			self::ERR_INTERNAL_ERROR => 'Internal Error',
			self::ERR_PRECONDITION_FAILED => 'Precondition Failed',
			self::ERR_RESOURCE_NOT_FOUND => 'Resource Not Found',
			self::ERR_INVALID_RESOURCE => 'Invalid Resource',
			self::ERR_NOT_IMPLEMENTED => 'Feature not implemented',
			self::ERR_DISABLED => 'Feature Disabled',
			self::ERR_NETWORKING_DISABLED => 'Networking is Disabled',
		];

		return (isset($errors[$code])) ? $errors[$code] : '';
	}
505055
def get_info(self, code):
        """"""
        for i, currency in enumerate(self.get_currency(code)):
            if i == 0:
                try:
                    exp = int(currency.find('CcyMnrUnts').text)
                except ValueError:
                    exp = 0
                info = {
                    'CountryNames': [],
                    'ISO4217Number': int(currency.find('CcyNbr').text),
                    'ISO4217Exponent': exp,
                    'ISOUpdate': self.published.isoformat(),
                }
            try:
                ctry_name = currency.find('CtryNm').text
            except AttributeError:
                continue
            if ctry_name:
                info['CountryNames'] += [ctry_name]
        return info
472311
public static function getExpressByCode($code){
        if($code){
            $expresses = self::expresses();
            $express = array_filter($expresses,function ($express) use($code){
                return $express['code'] == $code;
            });
            if($express){
                return current($express);
            }
            return null;
        }
        return null;
    }
395940
protected function assertValidCode($code)
    {
        if ($code instanceof Money) {
            $code = $code->getCurrency();
        }

        if ($code instanceof Currency) {
            return (string) $code;
        }

        if (!is_string($code)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Currency code should be a string; %s given',
                gettype($code)
            ));
        }

        $code = trim(strtoupper($code));
        if (!Currencies::exists($code)) {
            throw new Exception\UnknownCurrencyException(sprintf(
                '%s is not a valid ISO 4217 Currency code',
                $code
            ));
        }

        return $code;
    }
1367875
def get_currencysymbol(self, code):
        """"""
        if not self._symbols:
            symbolpath = os.path.join(self._dir, 'currencies.json')
            with open(symbolpath, encoding='utf8') as df:
                self._symbols = json.load(df)
        return self._symbols.get(code)
1002439
private function getCurrencySymbol(string $currencyCode, string $locale): string
    {
        $formatter = new NumberFormatter($locale.'@currency='.$currencyCode, NumberFormatter::CURRENCY);

        return $formatter->getSymbol(NumberFormatter::CURRENCY_SYMBOL);
    }
1217013
public static function mapErrorCode($code)
    {
        $levelMap = [
            E_PARSE => 'error',
            E_ERROR => 'error',
            E_CORE_ERROR => 'error',
            E_COMPILE_ERROR => 'error',
            E_USER_ERROR => 'error',
            E_WARNING => 'warning',
            E_USER_WARNING => 'warning',
            E_COMPILE_WARNING => 'warning',
            E_RECOVERABLE_ERROR => 'warning',
            E_NOTICE => 'notice',
            E_USER_NOTICE => 'notice',
            E_STRICT => 'strict',
            E_DEPRECATED => 'deprecated',
            E_USER_DEPRECATED => 'deprecated',
        ];
        $logMap = [
            'error' => LOG_ERR,
            'warning' => LOG_WARNING,
            'notice' => LOG_NOTICE,
            'strict' => LOG_NOTICE,
            'deprecated' => LOG_NOTICE,
        ];

        $error = $levelMap[$code];
        $log = $logMap[$error];

        return [ucfirst($error), $log];
    }
934800
private function getCurrencyCode($currency)
    {
        $list = self::getCurrencyList();

        if (isset($list[$currency])) {
            return $list[$currency]['code'];
        }

        throw new \RuntimeException('Invalid exception provided');
    }
407284
protected function getCode($code)
    {
        if (is_array($code)) {
            return $this->getCodeArray($code);
        }

        return $this->get($code);
    }