function CurrencyLocalePattern::format in Currency 7.2
Formats an amount using this pattern.
Parameters
Currency $currency:
string $amount: A numeric string.
Return value
string
File
- currency/
includes/ CurrencyLocalePattern.inc, line 84 - Contains class CurrencyLocalePattern.
Class
- CurrencyLocalePattern
- A currency pattern for a locale.
Code
function format(Currency $currency, $amount) {
static $formatter = NULL;
if (is_null($formatter) || $formatter->pattern != $this->pattern) {
$formatter = new CurrencyFormatter($this->pattern, array(
CurrencyFormatter::SYMBOL_SPECIAL_DECIMAL_SEPARATOR => $this->symbol_decimal_separator,
CurrencyFormatter::SYMBOL_SPECIAL_GROUPING_SEPARATOR => $this->symbol_grouping_separator,
));
}
$formatted = $formatter
->format($amount, $currency->sign);
$formatted = str_replace(array(
'[XXX]',
'[999]',
), array(
$currency->ISO4217Code,
$currency->ISO4217Number,
), $formatted);
return $formatted;
}