How can I fix my code?
Cannot use positional argument after named argument
class getFormattedNumber
{
public $value;
public $locale;
public $style = NumberFormatter::DECIMAL;
public $precision = 2;
public $groupingUsed = true;
public $currencyCode = 'USD';
function set($value, $locale, $style, $precision, $groupingUsed, $currencyCode)
{
$this->value = $value;
$this->locale = $locale;
$this->style = $style;
$this->precision = $precision;
$this->groupingUsed = $groupingUsed;
$this->currencyCode = $currencyCode;
}
function get()
{
$formatter = new get($locale, $style);
$formatter->setAttribute(attribute: NumberFormatter::FRACTION_DIGITS, $precision);
$formatter->setAttribute(attribute: NumberFormatter::GROUPING_USED, $groupingUsed);
if ($style == NumberFormatter::CURRENCY) {
$formatter->setTextAttribute(attribute: NumberFormatter::CURRENCY_CODE, $currencyCode);
}
return $formatter->format($value);
}
}
$a = new getFormattedNumber();
$a->set(value: 12345678.9);
echo $a->get();