Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse doesn't allow country code to be blank #85

Closed
colouredFunk opened this issue Oct 13, 2015 · 3 comments
Closed

Parse doesn't allow country code to be blank #85

colouredFunk opened this issue Oct 13, 2015 · 3 comments

Comments

@colouredFunk
Copy link

If supplying an international number to parse, the country code should be optional.

$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
$number = $phoneUtil->parse($phone, "");

Example - http://libphonenumber.appspot.com/, enter a international number, leave step 2 and 3, it parse the number correctly and returns country code etc.

@giggsey
Copy link
Owner

giggsey commented Oct 13, 2015

I just tried that, and it works fine

require __DIR__ . '/vendor/autoload.php';

$phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance();

$phoneObj = $phoneNumberUtil->parse("+441174960000", '');

var_dump($phoneNumberUtil->isValidNumber($phoneObj));
var_dump($phoneNumberUtil->format($phoneObj, \libphonenumber\PhoneNumberFormat::E164));

Returns

bool(true)
string(13) "+441174960000"

That matches the Java API. The parameter is required, but can be null, or an empty string.

The demo might not allow empty country names, but I could fix that if that's the issue you're having.

@giggsey
Copy link
Owner

giggsey commented Oct 23, 2015

@colouredFunk Are you still having this issue?

@giggsey
Copy link
Owner

giggsey commented Oct 26, 2015

No reply for 3 days, closing.

If you are still having an issue, please reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants