public static function toInteger($string)
    {
        $lc = localeconv();

        $string = self::parseNegativeNotation($string);

        // change all locale formatting to numeric formatting
        $remove_parts = array(
            $lc['positive_sign'] => '',
            $lc['thousands_sep'] => ''
        );

        $value = str_replace(
            array_keys($remove_parts),
            array_values($remove_parts),
            $string
        );

        // note: This might be done better with a regexp, though
        // checking too closely how well a number matches its locale
        // formatting could become annoying too. i.e. if 1000 was
        // rejected because it wasn't formatted 1,000

        if (is_numeric($value)) {
            if ($value > (float) PHP_INT_MAX) {
                throw new SwatException(
                    'Floating point value is too big to be an integer'
                );
            }

            if ($value < (float) (-PHP_INT_MAX - 1)) {
                throw new SwatException(
                    'Floating point value is too small to be an integer'
                );
            }

            $value = intval($value);
        } else {
            $value = null;
        }

        return $value;
    }