locale = $locale; if (!in_array($style, self::VALID_STYLES, true)) { throw new \IntlException(str_replace(__NAMESPACE__ . '\\', '', __METHOD__) . '(): number formatter creation failed'); } $this->style = $style; } /** * @see \NumberFormatter::format() */ public function format($num, int $type = self::TYPE_DEFAULT) { $locale_switcher = new LocaleSwitcher(LC_NUMERIC, $this->locale); $locale_switcher->switch(); $locale_info = localeconv(); $locale_switcher->restore(); return number_format($num, 0, $locale_info['decimal_point'], $locale_info['thousands_sep']); } /** * @see \NumberFormatter::setAttribute() */ public function setAttribute(int $attribute, $value): bool { if (!in_array($attribute, self::VALID_ATTRIBUTES, true)) { return false; } $this->attributes[$attribute] = $value; return true; } /** * @see \NumberFormatter::setTextAttribute() */ public function setTextAttribute(int $attribute, string $value): bool { if (!in_array($attribute, self::VALID_TEXT_ATTRIBUTES, true)) { return false; } $this->text_attributes[$attribute] = $value; return true; } }