/** * Convert supplied currency information to the matching iso-4217 code * * @param string|int $currency currency iso code * * @return iso-4217 code */ private function _convertCurrency($currency) { if (is_numeric($currency)) { $currency = KlarnaCurrency::getCode($currency); } return strtoupper($currency); }
/** * Creates a locale * * @param string|int $country country of the locale * @param string|int $language language of the locale (optional) * @param string|int $currency currency of the locale (optional) */ public function __construct($country, $language = null, $currency = null) { $this->_country = self::parseCountry($country); // Set language from user input or from country default if (is_numeric($language)) { $language = KlarnaLanguage::getCode($language); } $this->_language = $language; // Set currency from user input or from country default if (is_numeric($currency)) { $currency = KlarnaCurrency::getCode($currency); } $this->_currency = $currency; }
/** * Returns the the currency code for the set currency constant. * * @param int {@link KlarnaCurrency Currency} constant. * @return string Three letter currency code. */ public function getCurrencyCode($currency = null) { $currency = $currency === null ? $this->currency : $currency; $code = KlarnaCurrency::getCode($currency); return $code === null ? '' : $code; }
/** * Returns the the currency code for the set currency constant. * * @param int $currency {@link KlarnaCurrency Currency} constant. * * @return string Three letter currency code. */ public function getCurrencyCode($currency = null) { if ($currency === null) { $currency = $this->_currency; } $code = KlarnaCurrency::getCode($currency); return (string) $code; }