@param int $value

@return string
329807
public static function encode($value)
    {
        $value = BigInteger::create($value);
        $octets = chr($value->modulus(0x80)->toInteger());

        $value = $value->shiftRight(7);
        while ($value->compare(0) > 0) {
            $octets .= chr(0x80 | $value->modulus(0x80)->toInteger());
            $value = $value->shiftRight(7);
        }

        return strrev($octets);
    }
890953
protected static function _encodeValue($value)
    {
        $string = '';

        switch (gettype($value))
        {
            case 'integer':
            case 'double':
                $string = $value;
                break;

            case 'boolean':
                $string = $value ? 'true' : 'false';
                break;

            case 'string':
                // Sanitize any CRLF characters..
                $string = '"' . str_replace(array("\r\n", "\n"), '\\n', $value) . '"';
                break;
        }

        return $string;
    }
843433
public function normalize($value)
    {
        if ($value) {
            if (is_int($value) || ctype_digit($value)) {
                $timestamp = $value;
            } elseif (!$timestamp = strtotime($value)) {
                return $value;
            }
            return date($this->_format, $timestamp);
        }
        return $value;
    }
428391
private function getTypedValue(string $value)
    {
        if (\in_array($value, self::$boolValues, true)) {
            return \in_array($value, self::$truthlyValues, true);
        }

        if (\is_numeric($value)) {
            return $this->getNumericValue($value);
        }

        return $value;
    }
822059
protected function valueToString($value) : string
    {
        if ($value === null) {
            $def_value = 'null';
        } elseif ($value === false) {
            $def_value = 'false';
        } elseif ($value === true) {
            $def_value = 'true';
        } elseif (is_string($value)) {
            $def_value = '"' . str_replace('"', '\\"', $value) . '"';
        } elseif (is_numeric($value)) {
            $def_value = '' . $value;
        }

        return $def_value;
    }
331723
protected function formatValue($value)
    {
        if ($this->formatValue !== NULL) {
            return str_replace(static::VALUE_IDENTIFIER, $value, $this->formatValue);
        } else {
            return $value;
        }
    }
317942
public function getAndSet(int $value): int
    {
        return intval($this->handle->getSet($this->name, strval($value)));
    }
1198606
protected function _quote($value)
    {
        if (is_int($value)) {
            return $value;
        } elseif (is_float($value)) {
            return sprintf('%F', $value);
        }

        return "'" . str_replace("'", "''", $value) . "'";
    }
1183069
public static function digits($value)
    {
        // we need to remove - and + because they're allowed in the filter
        $cleaned = str_replace(['-', '+'], '', $value);
        $cleaned = filter_var($cleaned, FILTER_SANITIZE_NUMBER_INT);

        return $cleaned;
    }
293984
public function appendInt32($value)
    {
        $s = pack("l", $value);
        return $this->append(self::$isLittleEndian ? self::swapEndian32($s) : $s);
    }
637695
protected function dumpValue($value): string
    {
        if (null === $value) {
            return 'null';
        }

        if (false === $value) {
            return 'false';
        }
        if (true === $value) {
            return 'true';
        }

        if (\is_int($value) || \is_float($value)) {
            return (string)$value;
        }

        if (\is_string($value)) {
            return StringHelper::dumpString($value);
        }

        throw new \InvalidArgumentException('Unsupported data type:' . gettype($value));
    }
1123505
public static function format($value)
    {
        $value = Utils::toString($value);
        $bn = Utils::toBn($value);
        $int = (int) $bn->toString();

        return $int;
    }
881602
public function encodeValue($value)
    {
        if ($this->urlEncode == self::RFC_3986) {
            return rawurlencode($value);
        } elseif ($this->urlEncode == self::FORM_URLENCODED) {
            return urlencode($value);
        } else {
            return (string) $value;
        }
    }
872904
public function formatValue($value)
    {
        $formatter = $this->getValueFormatter();
        return (string)($formatter ? call_user_func($formatter, $value, $this->getGrid()->getCurrentRow()) : $value);
    }
1226566
protected function _validate_int($value)
    {
        if (is_int($value)) {
            return $value;
        }

        return preg_match('#^[+-]?\d+$#', $value) ? (int)$value : null;
    }
1189816
public function filter(int $value) : string
    {
        if ($value < 0) {
            throw new Exception(sprintf('Invalid integer: %d', $value), Exception::INVALID_INTEGER);
        }

        $tokens = $this->getGrammar()->getTokens();
        $values = array_reverse($this->getGrammar()->getValuesWithModifiers(), true /* preserve keys */);
        $result = '';

        if ($value === 0) {
            $dataset = $values[0];

            foreach ($dataset as $token) {
                $result = $result . $tokens[$token];
            }

            return $result;
        }

        foreach ($values as $current => $dataset) {
            while ($current > 0 && $value >= $current) {
                $value = $value - $current;
                foreach ($dataset as $token) {
                    $result = $result . $tokens[$token];
                }
            }
        }

        return $result;
    }
259501
protected function normalizeNumericStringValue($value)
    {
        $separatorPosition = strrpos($value, '.');
        
        if ($separatorPosition !== false) {
            $integerPart = substr($value, 0, $separatorPosition);
            $fractionalPart = substr($value, $separatorPosition + 1);
        } else {
            $integerPart = $value;
            $fractionalPart = null;
        }
        
        // truncate insignificant zeros, keep minus
        $integerPart = preg_replace('/^\+?(-?)0*(\d+)$/', '$1$2', $integerPart);
        // for zeros only leave one zero, keep minus
        $integerPart = preg_replace('/^\+?(-?)0*$/', '${1}0', $integerPart);
        
        if ($fractionalPart !== null) {
            // truncate insignificant zeros
            $fractionalPart = rtrim($fractionalPart, '0');
        }
        
        $normalizedValue = $integerPart;
        if (!empty($fractionalPart)) {
            $normalizedValue .= '.' . $fractionalPart;
        } elseif ($normalizedValue === '-0') {
            $normalizedValue = '0';
        }
        
        return $normalizedValue;
    }