Parse if a value is numeric and cast it
to its correct type.

@param string $value

@return float|int
343296
protected function parseNumeric($value)
    {
        if (is_numeric($value)) {
            if (false !== strrpos($value, '.')) {
                return (float) $value;
            }

            return (int) $value;
        }

        return $value;
    }
1228280
protected function isValid($value)
    {
        if (is_float($value)) {
            return;
        }
        if (!is_string($value) || strpos($value, '.') === false || preg_match('/^[0-9.e+-]+$/', $value) !== 1) {
            $this->addError('A valid float number is expected.', 1221560288);
        }
    }
1244164
protected static function normalizeValue($value)
    {
        if (is_bool($value)) {
            $value = (bool)$value;
            return $value;
        } elseif (is_numeric($value)) {
            return (int)$value;
        }
        return $value;
    }
765776
protected static function prepareNumericCast($value)
    {
        if (!in_array(gettype($value), static::$numericCastable, true)) {
            return '';
        }
        if (is_string($value)) {
            return trim($value);
        }
        return $value;
    }
37492
protected function convertType(string $value)
    {
        $val = \mb_strtolower($value);
        if ($val === 'true') {
            return true;
        } elseif ($val === 'false') {
            return false;
        } elseif ($val === 'null') {
            return null;
        } elseif (\mb_strpos($val, '.') !== false && \is_numeric($val)) {
            return (float) $val;
        } elseif (\is_numeric($val)) {
            return (int) $val;
        }

        return $this->replaceVariables($value);
    }
841441
public static function parseString($value) {
        try {
            return FloatHelper::parseString($value);
        } catch (FloatArgumentException $ex) {
            throw new DoubleArgumentException($value, $ex);
        }
    }
1297323
public function marshal($value)
    {
        if ($value === null || $value === '') {
            return null;
        }
        if (is_string($value) && $this->_useLocaleParser) {
            return $this->_parseValue($value);
        }
        if (is_numeric($value)) {
            return (float)$value;
        }
        if (is_string($value) && preg_match('/^[0-9,. ]+$/', $value)) {
            return $value;
        }

        return null;
    }
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;
    }
1124769
public static function float($value){

		$value = static::_nullValue($value);

		if($value !== null){

			// Avoid decimal separator nonsense
			$value = str_replace(',', '.', $value);
			$value = (float) $value;
		}

		return $value;
	}
610735
private function isInt(string $value): bool
    {
        return \is_numeric($value) && (float)\round($value, 0) === (float)$value;
    }
872248
private static function parseReal($value)
    {
        if ($value == '') return null;

        $x = str_replace(',', '.', $value);
        if (static::isSignedReal($x)) return floatval($x);
        else throw new SyntaxErrorException();
    }
838939
public function castItemValueToProperType($value)
    {
        $normalized = $value;

        if (in_array($value, ['true', 'on', 'yes']))
        {
            $normalized = true;
        }
        elseif (in_array($value, ['false', 'off', 'no', 'none']))
        {
            $normalized = false;
        }
        elseif ('null' == $value)
        {
            $normalized = null;
        }
        elseif (is_numeric($value))
        {
            $number = $value + 0;
            if (intval($number) == $number)
            {
                $normalized = (int)$number;
            }
            elseif (floatval($number) == $number)
            {
                $normalized = (float)$number;
            }
        }
        elseif (is_array($value))
        {
            foreach ($value as $itemKey => $itemValue)
            {
                $normalized[$itemKey] = $this->castItemValueToProperType($itemValue);
            }
        }
        return $normalized;
    }
1236315
protected function validateNumber($value)
    {
        $return = new ValidateResult($value, false);

        if (is_string($value)) {
            //Replace comma with dot
            $value = str_replace(',', '.', $value);
        }

        //Apply all rules
        if (!is_numeric($value) || filter_var($value, FILTER_VALIDATE_FLOAT) === false) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'type'
                ]
            ]);
        } elseif ($this->maximum !== null
            && ($value > $this->maximum
                || ($this->exclusiveMaximum === true && $value >= $this->maximum)
            )
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'maximum'
                ]
            ]);
        } elseif ($this->minimum !== null
            && ($value < $this->minimum
                || ($this->exclusiveMinimum === true && $value <= $this->minimum)
            )
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'minimum'
                ]
            ]);
        } elseif ($this->multipleOf !== null
            && fmod((float)$value, (float)$this->multipleOf) != 0
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'multipleOf'
                ]
            ]);
        } else {
            $return->errorObject = null;
            //Set status to success
            $return->status = true;
            //Type cast
            $return->value  = $this->cast($value);
        }

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

        return (int) $value;
    }
122362
public static function int($value): int
    {
        $cleaned = preg_replace('#[^0-9-+.,]#', '', $value);
        preg_match('#[-+]?[\d]+#', $cleaned, $matches);
        $result = $matches[0] ?? 0;

        return (int)$result;
    }
902916
public static function castInt($value): int
    {
        if ($value !== null && !is_scalar($value)) {
            throw new InvalidArgumentException('Value could not be parsed to integer');
        }

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

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

		return Type::STRING;
	}