Returns rule that formats numbers

@param int $decimals
@param string $decimalPoint
@param string $thousandSeparator
@return $this
335649
public function numberFormat($decimals, $decimalPoint, $thousandSeparator)
    {
        return $this->addRule(new FilterRule\NumberFormat($decimals, $decimalPoint, $thousandSeparator));
    }
1173509
public static function roundFixed($value, $decimals = 2)
    {
        $value = round($value, $decimals);

        $pos = strpos($value, '.');

        if ($pos === false) {
            $value .= '.' . str_repeat('0', $decimals);
        } else {
            $extra = $decimals - strlen($value) + $pos + 1;
            if ($extra > 0) {
                $value .= str_repeat('0', $extra);
            }
        }

        return $value;
    }
554512
public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = null)
    {
        return $this->numberFormat($this->tax, $decimals, $decimalPoint, $thousandSeperator);
    }
835361
function (number, decimals, decPoint, thousandsSep) {

            number = ("" + number).replace(/[^0-9+\-Ee.]/g, "");

            var num        = !isFinite(+number) ? 0 : +number,
                prec       = !isFinite(+decimals) ? 0 : Math.abs(decimals),
                separator  = thousandsSep === undefined ? "," : thousandsSep,
                decimal    = decPoint === undefined ? "." : decPoint,
                toFixedFix = function (n, prec) {
                    var k = Math.pow(10, prec);
                    return "" + (Math.round(n * k) / k).toFixed(prec);
                },

                // Fix for IE parseFloat(0.55).toFixed(0) = 0;
                result     = (prec ? toFixedFix(num, prec) : "" + Math.round(num)).split(".");

            if (result[0].length > 3) {
                result[0] = result[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, separator);
            }

            return result.join(decimal);
        }
662715
public static function nReal($number, $decimals = 2, $symbol = true, $fixed = true)
    {
        if (is_null($number) || empty(self::onlyNumbers($number))) {
            return '';
        }
        $formater = new \NumberFormatter("pt-BR", \NumberFormatter::CURRENCY);
        $formater->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, ($fixed ? $decimals : 1));
        if ($decimals === false) {
            $decimals = 2;
            preg_match_all('/[0-9][^0-9]([0-9]+)/', $number, $matches);
            if (!empty($matches[1])) {
                $decimals = mb_strlen(rtrim($matches[1][0], 0));
            }
        }
        $formater->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
        if (!$symbol) {
            $pattern = preg_replace("/[¤]/", '', $formater->getPattern());
            $formater->setPattern($pattern);
        } else {
            // ESPAÇO DEPOIS DO SIMBOLO
            $pattern = str_replace("¤", "¤ ", $formater->getPattern());
            $formater->setPattern($pattern);
        }
        return $formater->formatCurrency($number, $formater->getTextAttribute(\NumberFormatter::CURRENCY_CODE));
    }
932525
public static function decimal( $value, $decimals = 2 )
	{
		$nf = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
		$nf->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
		return $nf->format($value);
	}
1040930
public function number($number, $decimals = 0)
    {
        return number_format(
            (float) $number,
            $decimals,
            $this->get('number')['decimal_separator'],
            $this->get('number')['thousands_separator']
        );
    }
603423
public function value(float $value, int $decimal_points = null): string
    {
        if (is_null($decimal_points)) {
            return $value;
        }

        return $this->decimal($value, $decimal_points);
    }
1203015
public function format($decimals = 2, $point = '.', $thousands_sep = ',', $currency = null) {

		if(false === ('-' . intval($decimals) == '-' . $decimals)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($decimals)), E_USER_ERROR);
		}

		if(false === is_string($point)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($point)), E_USER_ERROR);
		}

		if(false === is_string($thousands_sep)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($thousands_sep)), E_USER_ERROR);
		}

		if(null !== $currency && false === is_string($currency)) {
			return trigger_error(sprintf('Argument 4 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($currency)), E_USER_ERROR);
		}

		return $this -> convert(function($number, $decimals, $point, $thousands_sep, $currency) {
			return ($currency ?: $currency) . number_format($number, $decimals, $point, $thousands_sep);
		}, [$decimals, $point, $thousands_sep, $currency]);
	}
236917
public function format($decimals = 0, $decPoint = '.', $thousandsSep = ' ')
    {
        $decimals = max(0, (int) $decimals);
        $dec      = '';
        // do not mutate
        $number   = (new static($this))->round($decimals)->normalize();
        $sign     = $number->isPositive() ? '' : '-';
        if ($number->abs()->hasDecimals()) {
            list($number, $dec) = explode('.', (string) $number);
        }

        if ($decimals) {
            $dec = sprintf("%'0-" . $decimals . 's', $dec);
        }

        return $sign . preg_replace("/(?<=\d)(?=(\d{3})+(?!\d))/", $thousandsSep, $number) . ($decimals ? $decPoint . $dec : '');
    }
1078746
public function format($decimals = 2, $decPoint = '.', $thousandSep = ',')
    {
        return number_format($this->value, $decimals, $decPoint, $thousandSep);
    }
930225
public static function formatToNumber($value, $decimals = 2)
    {
        if (trim($value) != null) {
            return number_format($value, $decimals, '.', '');
        }
        return null;
    }
882160
public static void setDecimals(int decimals) {
        FuzzyLite.decimals = decimals;
        DecimalFormat decimalFormat = FORMATTER.get();
        decimalFormat.setMinimumFractionDigits(decimals);
        decimalFormat.setMaximumFractionDigits(decimals);
    }
844704
public function formatPercent($value, $maximumFractionDigits=0, $minimumFractionDigits=0)
    {
        $newValue = trim($value, " \0\x0B%");
        if (!is_numeric($newValue)) {
            return $value;
        }

        $pattern = $this->getPattern($value, 'Intl_NumberFormatPercent');

        return $this->formatNumberWithPattern($pattern, $newValue, $maximumFractionDigits, $minimumFractionDigits);
    }
203933
public static function calculate_percentage($numerator, $denominator, $decimals = 2, $dec_point = '.', $thousands_sep = ',')
    {
        return number_format(($numerator / $denominator) * 100, $decimals, $dec_point, $thousands_sep);
    }
1218792
public static function format($number, $decimals = null, $decimalPoint = null,
                                  $thousandsSeparator = null)
    {
        if (is_null($decimals)) {
            $decimals = self::$decimals;
        }
        if (is_null($decimalPoint)) {
            $decimalPoint = self::$decimalPoint;
        }
        if (is_null($thousandsSeparator)) {
            $thousandsSeparator = self::$thousandsSeparator;
        }
        return number_format($number, $decimals, $decimalPoint, $thousandsSeparator);
    }
810604
private function numberFormat($value, $decimals, $decimalPoint, $thousandSeperator)
    {
        if (is_null($decimals)){
            $decimals = is_null(config('cart.format.decimals')) ? 2 : config('cart.format.decimals');
        }

        if (is_null($decimalPoint)){
            $decimalPoint = is_null(config('cart.format.decimal_point')) ? '.' : config('cart.format.decimal_point');
        }

        if (is_null($thousandSeperator)){
            $thousandSeperator = is_null(config('cart.format.thousand_seperator')) ? ',' : config('cart.format.thousand_seperator');
        }

        return number_format($value, $decimals, $decimalPoint, $thousandSeperator);
    }