-
Notifications
You must be signed in to change notification settings - Fork 468
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
Method maybeExtractCountryCode very slowly #444
Comments
$phoneNumberUtil = PhoneNumberUtil::getInstance();
$phoneNumberObject = $phoneNumberUtil->parse('+79636417683');
$serializedPhoneNumber = serialize($phoneNumberObject);
echo $serializedPhoneNumber.PHP_EOL;
$phoneNumberObjectFromUnserialized = unserialize($serializedPhoneNumber);
dump($phoneNumberObjectFromUnserialized);
$this->assertEquals(
$phoneNumberUtil->getNumberType($phoneNumberObject),
$phoneNumberUtil->getNumberType($phoneNumberObjectFromUnserialized)
);
$this->assertEquals(
$phoneNumberUtil->format($phoneNumberObject, PhoneNumberFormat::E164),
$phoneNumberUtil->format($phoneNumberObjectFromUnserialized, PhoneNumberFormat::E164)
);
$this->assertEquals(
$phoneNumberUtil->canBeInternationallyDialled($phoneNumberObject),
$phoneNumberUtil->canBeInternationallyDialled($phoneNumberObjectFromUnserialized)
);
$this->assertEquals(
$phoneNumberUtil->truncateTooLongNumber($phoneNumberObject),
$phoneNumberUtil->truncateTooLongNumber($phoneNumberObjectFromUnserialized)
);
$this->assertEquals(
$phoneNumberUtil->truncateTooLongNumber($phoneNumberObject),
$phoneNumberUtil->truncateTooLongNumber($phoneNumberObjectFromUnserialized)
); It's working ok
Dump after unserialize:
Can you tell me if there could be any problems when using the serialize phone number object function? |
Serialization is unit tested, so it should be absolutely fine for your needs there. As for speed improvements, MRs are welcome, providing it doesn't deviate too much from the Java version of Google's library. Just looking through the code, there are a bunch of calls |
Replace all checks of mb_strlen is 0 by direct compare to empty string closes giggsey#444
…son) Replace all checks of mb_strlen is greater than 0 by direct compare to not equal to empty string closes giggsey#444
i replaced |
Maybe need add mechanism for cache of parsing?
How I can cache or serialize phonenumber phone for cache?
The text was updated successfully, but these errors were encountered: