- function df_currency($currency = null) {
- /** @var Currency $result */
- if (!$currency) {
- $result = df_currency_base();
- }
- else if ($currency instanceof Currency) {
- $result = $currency;
- }
- else {
- /** @var array(string => Currency) $cache */
- static $cache;
- if (!isset($cache[$currency])) {
- $cache[$currency] = df_create(Currency::class)->load($currency);
- }
- $result = $cache[$currency];
- }
- return $result;
- }