function DecimalFormatter::__construct in Currency 7.2
Overrides parent::__construct().
Overrides IntegerFormatter::__construct
File
- currency/
vendor/ bartfeenstra/ cldr/ src/ BartFeenstra/ CLDR/ DecimalFormatter.php, line 39 - Contains class \BartFeenstra\CLDR\IntegerFormatter.
Class
- DecimalFormatter
- Formats a decimal according CLDR number pattern guidelines.
Namespace
BartFeenstra\CLDRCode
function __construct($pattern, array $symbol_replacements = array()) {
$this->pattern = $pattern;
$this->symbol_replacements = $symbol_replacements;
$symbols = $this
->patternSymbolsSplit($this
->patternSymbols($pattern), self::SYMBOL_PATTERN_SEPARATOR, TRUE);
// If there is no negative pattern, add a default.
if ($symbols[self::NEGATIVE] === FALSE) {
$pattern .= ';-' . $pattern;
$symbols = $this
->patternSymbolsSplit($this
->patternSymbols($pattern), self::SYMBOL_PATTERN_SEPARATOR, TRUE);
}
foreach ($symbols as $sign_symbols) {
if (empty($sign_symbols)) {
throw new \InvalidArgumentException('Empty number pattern.');
}
}
$this->symbols = array(
$this
->patternSymbolsSplit($symbols[self::POSITIVE], self::SYMBOL_SPECIAL_DECIMAL_SEPARATOR),
$this
->patternSymbolsSplit($symbols[self::NEGATIVE], self::SYMBOL_SPECIAL_DECIMAL_SEPARATOR),
);
}