Converts human-readable value to plain
@param $value
@return int
774177
public static function humanToPlain($value)
    {
        $l = substr($value, -1);

        if ($l === 'b' || $l === 'B') {
            return ((int)substr($value, 0, -1));
        }

        if ($l === 'k') {
            return ((int)substr($value, 0, -1) * 1000);
        }

        if ($l === 'K') {
            return ((int)substr($value, 0, -1) * 1024);
        }

        if ($l === 'm') {
            return ((int)substr($value, 0, -1) * 1000 * 1000);
        }

        if ($l === 'M') {
            return ((int)substr($value, 0, -1) * 1024 * 1024);
        }

        if ($l === 'g') {
            return ((int)substr($value, 0, -1) * 1000 * 1000 * 1000);
        }

        if ($l === 'G') {
            return ((int)substr($value, 0, -1) * 1024 * 1024 * 1024);
        }

        return (int)$value;
    }
943738
public function displayValue( $value )
    {
        if ( $this->getUseRegularExpression() )
        {
            return preg_replace( $this->getFrom(), $this->getTo(), $value );
        }
        else
        {
            return str_replace( $this->getFrom(), $this->getTo(), $value );
        }
    }
1296265
private function parseIniSize($value) {
		$units = ['k' => 1024, 'm' => 1048576, 'g' => 1073741824];
		$unit = strtolower(substr($value, -1));
		if(is_numeric($unit) || !isset($units[ $unit ])) {
			return $value;
		}
		
		return ((int)$value) * $units[ $unit ];
	}
136477
protected function parseToEnglish(string $value): string
    {
        if (ctype_digit($value)) {
            return $value;
        }
        $localeConv = $this->getLocaleInfo();
        $replacements = [$localeConv['thousands_sep'], $localeConv['currency_symbol'], ' ', "\t"];
        $value = $this->numberToEnglish(str_replace($replacements, '', $value));
        return (! is_numeric($value)) ? '0' : $value;
    }
263820
public static function getHumanReadableBytes($value)
    {
        static $unit = array('B', 'KB', 'MB', 'GB', 'TB');

        $i = \floor(\log($value, 1024));
        $i = \min($i, 4); // Only go up to TB

        return array(
            'value' => (float) ($value / \pow(1024, $i)),
            'unit' => $unit[$i],
        );
    }
1076148
protected function getValueAsIni($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;
	}
804936
public static function humanToPlain($value)
    {
        $time = 0;

        preg_replace_callback('~(\d+(\.\d+)?)\s*([smhd])\s*|(.+)~i', function ($m) use (&$time) {
            if (isset($m[4]) && ($m[4] !== '')) {
                $time = false;
            }

            if ($time === false) {
                return;
            }

            if (!empty($m[2])) {
                $n = (float)$m[1];
            } else {
                $n = (int)$m[1];
            }

            $l = strtolower($m[3]);

            if ($l === 's') {
                $time += $n;
            } elseif ($l === 'm') {
                $time += $n * 60;
            } elseif ($l === 'h') {
                $time += $n * 60 * 60;
            } elseif ($l === 'd') {
                $time += $n * 60 * 60 * 24;
            }
        }, $value);

        return $time;
    }
1090488
private function getValueType($value)
	{
		if (is_numeric($value)) {
			return Type::NUMBER;
		}

		if (is_array($value)) {
			return Type::STRING_SET;
		}

		return Type::STRING;
	}
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;
    }
827080
private function formatValue($value)
    {
        if ($value === '') {
            return '';
        }

        if ($value === null) {
            return '<comment>Null</comment>';
        }

        if (is_bool($value)) {
            return '<comment>' . ($value ? 'True' : 'False') . '</comment>';
        }

        if (empty($value)) {
            return '<comment>Empty</comment>';
        }

        if (is_array($value)) {
            return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
        }

        if (is_object($value)) {
            return sprintf('<%s>', get_class($value));
        }

        if (is_scalar($value)) {
            return $value;
        }

        throw new InvalidArgumentException(sprintf('Do not know how to format value "%s"', print_r($value, true)));
    }
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;
    }
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);
    }
1020075
protected static function pad($value)
        {
            $pad = static::$block - (Inflector::length($value) % static::$block);
            return $value .= str_repeat(chr($pad), $pad);
        }
1163135
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return;
        }
        $formatted = \number_format($value, 2, ',', '.');

        return $formatted;
    }
192971
public static function toInt($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException(
                "The \$value parameter must be numeric (or string representing a big number)."
            );
        }

        if (is_int($value)) {
            return $value;
        } elseif (is_float($value)) {
            return (int)$value;
        }

        if (($decimal = Str::pos($value, '.')) !== false) {
            $value = Str::sub($value, 0, (int)$decimal);
        }

        return $value;
    }
1099469
public static function convertToBytes(string $value): int
    {
        $units = "BKMGT";
        $unit = preg_replace("/[^$units]/i", "", $value);
        $value = floatval($value);
        if ($unit) {
            $value *= pow(1024, stripos($units, $unit[0]));
        }

        return (int) $value;
    }
659048
protected function transformValue($value)
    {
        // first of all remove any quotation marks
        $value = preg_replace('/("|\')(.+)("|\')/', '$2', $value);

        $this->transformToDate($value);
        $this->transformToFloat($value);
        $this->transformToInt($value);

        return $value;
    }