returns the formatted number with grouped thousands

@param     $value
@param int $decimals

@return null|string
979379
public static function format($value, int $decimals = 2): ?string {
        if (!\is_numeric($value)) {
            return null;
        }
        return \number_format($value, $decimals);
    }
1163135
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return;
        }
        $formatted = \number_format($value, 2, ',', '.');

        return $formatted;
    }
1157801
public function setFormat($decimals = 0, $dec_point = '.', $thousands_sep = ' ')
	{
		$this->number_format = [$decimals, $dec_point, $thousands_sep];

		return $this;
	}
661633
public static function formatAsMoney($value, $currencySymbol = "&pound;", $roundToInteger = false) {
        if (is_numeric($value))
            return $currencySymbol . number_format($value, $roundToInteger ? 0 : 2, ".", "");
        else
            return null;
    }
394714
public static function format($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',')
    {
        return \number_format($number, $decimals, $decPoint, $thousandsSep);
    }
702188
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false)
    {
        $value     = PHPExcel_Calculation_Functions::flattenSingleValue($value);
        $decimals  = PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
        $no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);

        // Validate parameters
        if (!is_numeric($value) || !is_numeric($decimals)) {
            return PHPExcel_Calculation_Functions::NaN();
        }
        $decimals = floor($decimals);

        $valueResult = round($value, $decimals);
        if ($decimals < 0) {
            $decimals = 0;
        }
        if (!$no_commas) {
            $valueResult = number_format($valueResult, $decimals);
        }

        return (string) $valueResult;
    }
1318598
public function convert($value, $from, $to, $decimals = 2)
    {
        return (float) $this->from($value, $from)->to($to, $decimals, !empty($decimals));
    }
899281
public function format($value): string
    {
        $formatter = new NumberFormatter($this->locale(), NumberFormatter::CURRENCY);

        if ($value instanceof MoneyInterface) {
            $value = $value->toMoney();
        }

        if ($value instanceof ValueDiscount) {
            $value = $value->rate();
        }

        $code = $this->code($value);
        $divisor = $this->divisor($code);
        $amount = $this->convert($value, $divisor);

        return $formatter->formatCurrency($amount, $code);
    }
637885
private function format($value)
    {
        if (is_callable($this->formatter)) {
            $value = call_user_func($this->formatter, $value, $this->dataSet);
        }
        return $value;
    }
536743
public static function VALUE($value = '')
    {
        $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);

        if (!is_numeric($value)) {
            $numberValue = str_replace(
                PHPExcel_Shared_String::getThousandsSeparator(),
                '',
                trim($value, " \t\n\r\0\x0B" . PHPExcel_Shared_String::getCurrencyCode())
            );
            if (is_numeric($numberValue)) {
                return (float) $numberValue;
            }

            $dateSetting = PHPExcel_Calculation_Functions::getReturnDateType();
            PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);

            if (strpos($value, ':') !== false) {
                $timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($value);
                if ($timeValue !== PHPExcel_Calculation_Functions::VALUE()) {
                    PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
                    return $timeValue;
                }
            }
            $dateValue = PHPExcel_Calculation_DateTime::DATEVALUE($value);
            if ($dateValue !== PHPExcel_Calculation_Functions::VALUE()) {
                PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
                return $dateValue;
            }
            PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);

            return PHPExcel_Calculation_Functions::VALUE();
        }
        return (float) $value;
    }
126769
private function getNumericValue(string $value)
    {
        if (\strpos($value, '.') !== false) {
            return (float) $value;
        }

        return (int) $value;
    }
1068175
public static function format($value)
    {
        if (isset($value['priority'])) {
            $value['priority'] = QuantityFormatter::format($value['priority']);
        }
        if (isset($value['ttl'])) {
            $value['ttl'] = QuantityFormatter::format($value['ttl']);
        }
        return $value;
    }
449364
protected function formatValue($format, $value)
    {
        // TODO : Put in parameters
        $decimals = 2;
        $dec_point = ',';
        $thousands_sep = ' ';

        switch ($format) {
            case Format::DATE:
                if ($value instanceof \DateTime) {
                    return $value->format('d/m/Y');
                }
                break;

            case Format::DATETIME:
                if ($value instanceof \DateTime) {
                    return $value->format('d/m/Y H:i:s');
                }
                break;

            case Format::FLOAT2:
                return str_replace($dec_point."00", "",number_format(floatval($value), $decimals, $dec_point, $thousands_sep));

            case Format::INTEGER:
                return number_format(intval($value), 0, $dec_point, $thousands_sep);

            case Format::PCT:
                return $this->formatValue(Format::INTEGER, $value*100)."%";

            case Format::PCT2:
                return $this->formatValue(Format::FLOAT2, $value*100)."%";

            case Format::MONEY:
                return $this->formatValue(Format::INTEGER, $value)."€";

            case Format::MONEY2:
                return $this->formatValue(Format::FLOAT2, $value)."€";
        }

        return $value;
    }
1123505
public static function format($value)
    {
        $value = Utils::toString($value);
        $bn = Utils::toBn($value);
        $int = (int) $bn->toString();

        return $int;
    }
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);
	}
515525
private function number_format($number, $decimal_precision = 0, $decimals_separator = '.', $thousands_separator = ',') {
        $number = explode('.', str_replace(' ', '', $number));
        $number[0] = str_split(strrev($number[0]), 3);
        $total_segments = count($number[0]);
        for ($i = 0; $i < $total_segments; $i++) {
            $number[0][$i] = strrev($number[0][$i]);
        }
        $number[0] = implode($thousands_separator, array_reverse($number[0]));
        if (!empty($number[1])) {
           $number[1] = round($number[1], $decimal_precision);
        }
        return implode($decimals_separator, $number);
    }
189175
public function decimal($values)
    {
        //For reference, this is what typically gets passed to this function:
        //$parts=Array('datatype'=>'decimal', 'precision'=>"$this->wholeSize,$this->decimalSize");
        //DB::requireField($this->tableName, $this->name, "decimal($this->wholeSize,$this->decimalSize)");
        // Avoid empty strings being put in the db
        if ($values['precision'] == '') {
            $precision = 1;
        } else {
            $precision = $values['precision'];
        }

        // Fix format of default value to match precision
        if (isset($values['default']) && is_numeric($values['default'])) {
            $decs = strpos($precision, ',') !== false
                    ? (int) substr($precision, strpos($precision, ',') + 1)
                    : 0;
            $values['default'] = number_format($values['default'], $decs, '.', '');
        } else {
            unset($values['default']);
        }

        return "decimal($precision) not null" . $this->defaultClause($values);
    }