private static function convertToNumber(string $number): string
    {
        \preg_match_all('/(\D+)/', $number, $matches);

        if (\count(\array_unique($matches[0])) > 1) {
            throw new InvalidArgumentException(
                "The number '{$number}' seems to have decimal part. Only integer numbers are supported."
            );
        }

        return \preg_replace('/\D+/', '', $number);
    }
private static function convertToNumber(string $number): string
    {
        \preg_match_all('/(\D+)/', $number, $matches);

        if (\count(\array_unique($matches[0])) > 1) {
            throw new InvalidArgumentException(
                "The number '{$number}' seems to have decimal part. Only integer numbers are supported."
            );
        }

        return \preg_replace('/\D+/', '', $number);
    }
private static function convertToNumber ( string $ number ) : string { \ preg_match_all ( '/(\D+)/' , $ number , $ matches ) ; if ( \ count ( \ array_unique ( $ matches [ 0 ] ) ) > 1 ) { throw new InvalidArgumentException ( "The number '{$number}' seems to have decimal part. Only integer numbers are supported." ) ; } return \ preg_replace ( '/\D+/' , '' , $ number ) ; }
Remove non-numeric characters in the string to cast it to a numeric value.

Incoming number can be presented in arbitrary format that depends on locale. We don't possess locale information.
So the best can be done is to treat number as an integer and eliminate delimiters.
Method will not behave correctly with non-integer numbers for the following reason:
- if value has more than one delimiter, such as in French notation: "1 234,56" -- then we can infer decimal part
- but the value has only one delimiter, such as "234,56", then it is impossible to know whether it is decimal
separator or not. Only knowing the right format would allow this.

@param string $number

@throws \InvalidArgumentException

@return string
Remove non - numeric characters in the string to cast it to a numeric value .