format

@param mixed $value
@return string
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;
    }
370804
protected function formatValue($value)
    {
        if (is_array($value)) {
            return Formatter::formatArray($value);
        }

        return Formatter::formatScalar($value);
    }
882344
protected function formatValue($value)
    {
        $formatted_value = '<unknown parameter type>';

        if (is_object($value)) {
            $formatted_value = '<' . get_class($value) . ' object>';
        } elseif ($value === null) {
            $formatted_value = '<null>';
        } elseif (is_string($value)) {
            if (SwatString::validateUtf8($value)) {
                $formatted_value = "'" . $value . "'";
            } else {
                $formatted_value = '"' . SwatString::escapeBinary($value) . '"';
            }
        } elseif (is_int($value) || is_float($value)) {
            $formatted_value = strval($value);
        } elseif (is_bool($value)) {
            $formatted_value = $value ? 'true' : 'false';
        } elseif (is_resource($value)) {
            $formatted_value = '<resource>';
        } elseif (is_array($value)) {
            // check whether or not array is associative
            $keys = array_keys($value);
            $associative = false;
            $count = 0;
            foreach ($keys as $key) {
                if ($key !== $count) {
                    $associative = true;
                    break;
                }
                $count++;
            }

            $formatted_value = 'array(';

            $count = 0;
            foreach ($value as $key => $the_value) {
                if ($count > 0) {
                    $formatted_value .= ', ';
                }

                if ($associative) {
                    $formatted_value .= $this->formatValue($key);
                    $formatted_value .= ' => ';
                }
                $formatted_value .= $this->formatValue($the_value);
                $count++;
            }
            $formatted_value .= ')';
        }

        return $formatted_value;
    }
597918
private function formatByDayGrouping($value)
    {
        $value = $this->getTimestamp($value);
        if ('' === $value) {
            return '-';
        }
        $event = new ParseDateEvent($value, Config::get('dateFormat'));
        $this->dispatcher->dispatch(ContaoEvents::DATE_PARSE, $event);

        return $event->getResult();
    }
743180
public function format($format, $value)
    {
        switch ($format) {
            case 'date-time':
                return $this->formatDateTime($value);
            case 'date-time-http':
                return $this->formatDateTimeHttp($value);
            case 'date':
                return $this->formatDate($value);
            case 'time':
                return $this->formatTime($value);
            case 'timestamp':
                return $this->formatTimestamp($value);
            case 'boolean-string':
                return $this->formatBooleanAsString($value);
            default:
                return $value;
        }
    }
384438
public static function format($value)
    {
        $value = Utils::toString($value);

        if (Utils::isZeroPrefixed($value)) {
            // test hex with zero ahead, hardcode 0x0
            if ($value === '0x0' || strpos($value, '0x0') !== 0) {
                return $value;
            }
            $hex = preg_replace('/^0x0+(?!$)/', '', $value);
        } else {
            $bn = Utils::toBn($value);
            $hex = $bn->toHex(true);
        }
        if (empty($hex)) {
            $hex = '0';
        } else {
            $hex = preg_replace('/^0+(?!$)/', '', $hex);
        }
        return '0x' . $hex;
    }
331723
protected function formatValue($value)
    {
        if ($this->formatValue !== NULL) {
            return str_replace(static::VALUE_IDENTIFIER, $value, $this->formatValue);
        } else {
            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);
    }
729081
private function formatValueForApi($value)
    {
        $type = gettype($value);

        switch ($type) {
            case 'string':
                return ['string_value' => $value];
            case 'double':
            case 'integer':
                return ['number_value' => $value];
            case 'boolean':
                return ['bool_value' => $value];
            case 'NULL':
                return ['null_value' => NullValue::NULL_VALUE];
            case 'array':
                if (!empty($value) && $this->isAssoc($value)) {
                    return ['struct_value' => $this->formatStructForApi($value)];
                }

                return ['list_value' => $this->formatListForApi($value)];
        }
    }
1328429
public function prepareValue($value)
    {
        return $value === null ? null : Carbon::createFromFormat($this->format, $value)->toDateString();
    }
279641
public function getString($value)
    {
        $number = floatval($value);
        $number = round(($number + 0.000001) * 20) / 20;

        return sprintf('CHF %s',
            number_format($number, 2, '.', '\'')
        );
    }
403440
protected function formatValue($format, $value)
    {
        switch ($format) {
            case 'dash':
                return $this->inflector->dasherize($value);
            case 'underscore':
                return $this->inflector->underscore($value);
            case 'studlycaps':
                return $this->inflector->studlify($value);
            case 'camelcase':
                return $this->inflector->camelize($value);
            default:
                throw new RuntimeException('Unable to format value');
        }
    }
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);
    }
759179
private function prepareValue($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        if (strpos($value, "\n") !== false) {
            $values = explode("\n", $value);
            foreach ($values as &$line) {
                $line = $this->getIndentation(8) . $line;
            }
            $value = implode("\n", $values);

            return "|\n" . $value;
        }

        return '\'' . str_replace('\'', '\'\'', $value) . '\'';
    }
473429
public static function format($value)
    {
        $formatFunction = Config::get('shop.display_price_number_format') ?: function($price) { return number_format($price, 2); };
        return preg_replace(
            [
                '/:symbol/',
                '/:price/',
                '/:currency/'
            ],
            [
                Config::get('shop.currency_symbol'),
                $formatFunction($value),
                Config::get('shop.currency')
            ],
            Config::get('shop.display_price_format')
        );
    }
528730
public static function unformat($value)
    {
        if (is_array($value)) {
            foreach ($value as &$val) {
                $val = self::unformat($val);
            }
            return $value;
        }

        if (!$value) {
            $value = 0;
        }

        $neg = false;
        if (strpos($value, '-') === 0) {
            $neg = true;
        }

        $cleanString = preg_replace('/([^0-9\.,])/i', '', $value);
        $onlyNumbersString = preg_replace('/([^0-9])/i', '', $value);

        $separatorsCountToBeErased = strlen($cleanString) - strlen($onlyNumbersString)
            - 1;

        $stringWithCommaOrDot = preg_replace(
            '/([,\.])/',
            '',
            $cleanString,
            $separatorsCountToBeErased
        );
        $removedThousendSeparator = preg_replace(
            '/(\.|,)(?=[0-9]{3,}$)/',
            '',
            $stringWithCommaOrDot
        );

        $value = str_replace(',', '.', $removedThousendSeparator);
        if ($neg) {
            $value = -1 * abs($value);
        }
        return $value;
    }
526020
public static function format($format, $value)
    {
        switch ($format) {
            case 'date-time':
                return self::formatDateTime($value);
            case 'date-time-http':
                return self::formatDateTimeHttp($value);
            case 'date':
                return self::formatDate($value);
            case 'time':
                return self::formatTime($value);
            case 'timestamp':
                return self::formatTimestamp($value);
            case 'boolean-string':
                return self::formatBooleanAsString($value);
            default:
                return $value;
        }
    }