Example #1
0
 /**
  * 2016-09-06
  * Код платёжной валюты.
  * @param O|Q $oq [optional]
  * @return string
  */
 public function currencyC($oq = null)
 {
     return df_currency_code($oq ? $this->currencyFromOQ($oq) : $this->currency());
 }
Example #2
0
/**
 * 2016-06-30
 * «How to programmatically get a currency's name by its ISO code?» https://mage2.pro/t/1833
 * @param string|Currency|string[]|Currency[]|null $currency [optional]
 * @return string|string[]
 */
function df_currency_name($currency = null)
{
    /** @var string|string[] $result */
    if (is_array($currency)) {
        $result = array_map(__FUNCTION__, $currency);
    } else {
        /** @var \ResourceBundle $rb */
        static $rb;
        if (!isset($rb)) {
            $rb = (new CurrencyBundle())->get(df_locale())['Currencies'];
        }
        /** @var string $code */
        $code = is_string($currency) ? $currency : df_currency_code($currency);
        $result = $rb[$code][1] ?: $code;
    }
    return $result;
}