Format a siret number with 14 digits
@param string $value
@return string
774244
public static function formatSiret($value): string
    {
        $value = (string) (int) $value;
        if (!self::isSiret($value)) {
            return '';
        }
        return preg_replace('/^([0-9]{3})([0-9]{3})([0-9]{3})([0-9]{5})$/', '$1 $2 $3 $4', $value);
    }
1047231
public static function formatPercent(float $value) : string
    {
        $formatter = new NumberFormatter(self::translator()->getIETF(), NumberFormatter::PERCENT);

        return $formatter->format($value);
    }
1059911
public static function formatToInteger($value, $decimals = 2)
    {
        if (trim($value) != null) {
            return number_format($value, $decimals, '.', '') * 100;
        }
        return null;
    }
452858
public function encode39($Value)
    {
        $this->Result = "100101101101" . "0";
        $TextString = "";
        for ($i = 1; $i <= strlen($Value); $i++) {
            $CharCode = ord($this->mid($Value, $i, 1));
            if ($CharCode >= 97 && $CharCode <= 122) {
                $CharCode = $CharCode - 32;
            }

            if (isset($this->Codes[chr($CharCode)])) {
                $this->Result = $this->Result . $this->Codes[chr($CharCode)] . "0";
                $TextString = $TextString . chr($CharCode);
            }
        }

        if ($this->MOD43) {
            $Checksum = $this->checksum($TextString);
            $this->Result = $this->Result . $this->Codes[$Checksum] . "0";
        }

        $this->Result = $this->Result . "100101101101";
        $TextString = "*" . $TextString . "*";

        return $TextString;
    }
875341
public static function formatToDecimal($value, $decimals = 2)
    {
        if (trim($value) != null) {
            return number_format($value, $decimals, '.', '');
        }
        return null;
    }
1239422
protected function formatValue($value)
    {
        // If the value is a date we'll format it according to the specified
        // date format.
        if ($value instanceof DateTime || $value instanceof Carbon)
        {
            $value = $value->format($this->grammar->getDateFormat());
        }

        return $value;
    }
982042
static public function formatSearch($value)
    {
        $value = static::filter_xss($value);
        $value = static::html_entities($value);
        $value = str_replace('&lt;', '', $value);
        $value = str_replace('&gt;', '', $value);
        $value = static::sql_encode($value);
        $value = trim($value);
        
        return $value;
    }
1286033
public static function formatValueXml($value)
    {
        if (is_string($value)
            && !is_numeric($value)
        ) {
            $value = html_entity_decode($value, ENT_COMPAT, 'UTF-8');
            // make sure non-UTF-8 chars don't cause htmlspecialchars to choke
            if (function_exists('mb_convert_encoding')) {
                $value = @mb_convert_encoding($value, 'UTF-8', 'UTF-8');
            }
            $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');

            $htmlentities = array("&nbsp;", "&iexcl;", "&cent;", "&pound;", "&curren;", "&yen;", "&brvbar;", "&sect;", "&uml;", "&copy;", "&ordf;", "&laquo;", "&not;", "&shy;", "&reg;", "&macr;", "&deg;", "&plusmn;", "&sup2;", "&sup3;", "&acute;", "&micro;", "&para;", "&middot;", "&cedil;", "&sup1;", "&ordm;", "&raquo;", "&frac14;", "&frac12;", "&frac34;", "&iquest;", "&Agrave;", "&Aacute;", "&Acirc;", "&Atilde;", "&Auml;", "&Aring;", "&AElig;", "&Ccedil;", "&Egrave;", "&Eacute;", "&Ecirc;", "&Euml;", "&Igrave;", "&Iacute;", "&Icirc;", "&Iuml;", "&ETH;", "&Ntilde;", "&Ograve;", "&Oacute;", "&Ocirc;", "&Otilde;", "&Ouml;", "&times;", "&Oslash;", "&Ugrave;", "&Uacute;", "&Ucirc;", "&Uuml;", "&Yacute;", "&THORN;", "&szlig;", "&agrave;", "&aacute;", "&acirc;", "&atilde;", "&auml;", "&aring;", "&aelig;", "&ccedil;", "&egrave;", "&eacute;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&icirc;", "&iuml;", "&eth;", "&ntilde;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;", "&divide;", "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&yacute;", "&thorn;", "&yuml;", "&euro;");
            $xmlentities  = array("&#162;", "&#163;", "&#164;", "&#165;", "&#166;", "&#167;", "&#168;", "&#169;", "&#170;", "&#171;", "&#172;", "&#173;", "&#174;", "&#175;", "&#176;", "&#177;", "&#178;", "&#179;", "&#180;", "&#181;", "&#182;", "&#183;", "&#184;", "&#185;", "&#186;", "&#187;", "&#188;", "&#189;", "&#190;", "&#191;", "&#192;", "&#193;", "&#194;", "&#195;", "&#196;", "&#197;", "&#198;", "&#199;", "&#200;", "&#201;", "&#202;", "&#203;", "&#204;", "&#205;", "&#206;", "&#207;", "&#208;", "&#209;", "&#210;", "&#211;", "&#212;", "&#213;", "&#214;", "&#215;", "&#216;", "&#217;", "&#218;", "&#219;", "&#220;", "&#221;", "&#222;", "&#223;", "&#224;", "&#225;", "&#226;", "&#227;", "&#228;", "&#229;", "&#230;", "&#231;", "&#232;", "&#233;", "&#234;", "&#235;", "&#236;", "&#237;", "&#238;", "&#239;", "&#240;", "&#241;", "&#242;", "&#243;", "&#244;", "&#245;", "&#246;", "&#247;", "&#248;", "&#249;", "&#250;", "&#251;", "&#252;", "&#253;", "&#254;", "&#255;", "&#8364;");
            $value        = str_replace($htmlentities, $xmlentities, $value);
        } elseif ($value === false) {
            $value = 0;
        }

        return $value;
    }
546342
public static function formatTvaIntra($value)
    {
        $value = self::toUpper(trim(str_replace(' ', '', $value)));
        return preg_replace('/^([A-Z]{2})([0-9]{2})([0-9]{3})([0-9]{3})([0-9]{3})$/', '$1 $2 $3 $4 $5', $value);
    }
676273
public static function format(float $value) : string
    {
        $formatter = new NumberFormatter(self::translator()->getIETF(), NumberFormatter::DECIMAL);

        return $formatter->format($value);
    }
997387
public static function format($phone)
    {
        // Since we are a US-based application, we want to strip the "+1" US country code to facilitate formatting below
        if (substr($phone, 0, 3) == '+1 ') {
            $phone = str_replace('+1 ', '', $phone);
        }

        // US numbers will have 10 digits. Otherwise, leave alone.
        if (preg_match_all('/[0-9]/', $phone) == 10) {
            $phone = preg_replace('/[^0-9]/', '', $phone);
            $phone = '(' . substr($phone, 0, 3) . ') ' . substr($phone, 3, 3) . '-' . substr($phone, 6);
        }

        // Empty phone values should be made null
        if (empty($phone)) {
            $phone = null;
        }

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

        return (int) $value;
    }
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);
    }
1311567
private function _fix_pow($value) {

        // use value as literal
        $value = (string)$value;

        // if the power is present in the value
        if (preg_match('/E\-([0-9]+)$/', $value, $matches) > 0)

            // convert to human readable format
            $value = '0.' . str_repeat('0', $matches[1] - 1) . preg_replace('/\./', '', substr($value, 0, -strlen($matches[0])));

        // return the value
        return number_format($value, 3);

    }
169450
public static function format($value)
    {
        if (isset($value['gas'])) {
            $value['gas'] = QuantityFormatter::format($value['gas']);
        }
        if (isset($value['gasPrice'])) {
            $value['gasPrice'] = QuantityFormatter::format($value['gasPrice']);
        }
        if (isset($value['value'])) {
            $value['value'] = QuantityFormatter::format($value['value']);
        }
        if (isset($value['data'])) {
            $value['data'] = HexFormatter::format($value['data']);
        }
        if (isset($value['nonce'])) {
            $value['nonce'] = QuantityFormatter::format($value['nonce']);
        }
        return $value;
    }
289328
public function formatNumber($value, $maximumFractionDigits=0, $minimumFractionDigits=0)
    {
        $pattern = $this->getPattern($value, 'Intl_NumberFormatNumber');

        return $this->formatNumberWithPattern($pattern, $value, $maximumFractionDigits, $minimumFractionDigits);
    }
702446
public static function formataMoeda($value, $clean = true)
    {
        $value = (double)$value;

        return ($value || !$clean) ? number_format($value, 2, ',', '.') : '';
    }