protected function parseNumber($number)
    {
        $number = (string) $number;

        // remove whitespaces
        $number = trim($number);
        $number = str_replace(' ', '', $number);

        // remove + in front if exists
        if (substr($number, 0, 1) == '+') {
            $number = substr($number, 1);
        }

        // remove 0s in front if exists
        while (substr($number, 0, 1) === '0') {
            $number = substr($number, 1);
        }

        // we should at this point have a normal number
        if (!is_numeric($number)) {
            throw new \InvalidArgumentException("Invalid SMS recipient: $number");
        }

        // is phone number is less than 9 characters, assume we need to append
        // a country code
        if (strlen($number) <= 8) {
            throw new \InvalidArgumentException(
                "Recipient number is too short. Is the country code missing?: " . $number
            );
        }

        return $number;
    }
protected function parseNumber($number)
    {
        $number = (string) $number;

        // remove whitespaces
        $number = trim($number);
        $number = str_replace(' ', '', $number);

        // remove + in front if exists
        if (substr($number, 0, 1) == '+') {
            $number = substr($number, 1);
        }

        // remove 0s in front if exists
        while (substr($number, 0, 1) === '0') {
            $number = substr($number, 1);
        }

        // we should at this point have a normal number
        if (!is_numeric($number)) {
            throw new \InvalidArgumentException("Invalid SMS recipient: $number");
        }

        // is phone number is less than 9 characters, assume we need to append
        // a country code
        if (strlen($number) <= 8) {
            throw new \InvalidArgumentException(
                "Recipient number is too short. Is the country code missing?: " . $number
            );
        }

        return $number;
    }
protected function parseNumber ( $ number ) { $ number = ( string ) $ number ; // remove whitespaces $ number = trim ( $ number ) ; $ number = str_replace ( ' ' , '' , $ number ) ; // remove + in front if exists if ( substr ( $ number , 0 , 1 ) == '+' ) { $ number = substr ( $ number , 1 ) ; } // remove 0s in front if exists while ( substr ( $ number , 0 , 1 ) === '0' ) { $ number = substr ( $ number , 1 ) ; } // we should at this point have a normal number if ( ! is_numeric ( $ number ) ) { throw new \ InvalidArgumentException ( "Invalid SMS recipient: $number" ) ; } // is phone number is less than 9 characters, assume we need to append // a country code if ( strlen ( $ number ) <= 8 ) { throw new \ InvalidArgumentException ( "Recipient number is too short. Is the country code missing?: " . $ number ) ; } return $ number ; }
Parse a phone number.

@param  string $number

@return string
Parse a phone number .