src/Model/Payment.php
public static function priceStringToInt(string $str, string $propertyPath = '') : int
    {
        $str = trim($str);

        // verify format of string
        if (!preg_match('/(\.|,)[0-9]{2}$/', $str)) {
            throw new \InvalidArgumentException(($propertyPath ? $propertyPath.' (value: "'.$str.'")' : $str).
                ' does not match the currency string format');
        }
        $str = preg_replace('/[^0-9]+/', '', $str);

        return intval($str);
    }
public static function priceStringToInt(string $str, string $propertyPath = '') : int
    {
        $str = trim($str);

        // verify format of string
        if (!preg_match('/(\.|,)[0-9]{2}$/', $str)) {
            throw new \InvalidArgumentException(($propertyPath ? $propertyPath.' (value: "'.$str.'")' : $str).
                ' does not match the currency string format');
        }
        $str = preg_replace('/[^0-9]+/', '', $str);

        return intval($str);
    }
public static function priceStringToInt ( string $ str , string $ propertyPath = '' ) : int { $ str = trim ( $ str ) ; // verify format of string if ( ! preg_match ( '/(\.|,)[0-9]{2}$/' , $ str ) ) { throw new \ InvalidArgumentException ( ( $ propertyPath ? $ propertyPath . ' (value: "' . $ str . '")' : $ str ) . ' does not match the currency string format' ) ; } $ str = preg_replace ( '/[^0-9]+/' , '' , $ str ) ; return intval ( $ str ) ; }
Takes strings like
- 1.000,50
- 1,000.50
- 1000.50
- 1000,50.

and returns 100050

@param string $str
@param string $propertyPath

@return int
Takes strings like - 1 . 000 50 - 1 000 . 50 - 1000 . 50 - 1000 50 .