-
Notifications
You must be signed in to change notification settings - Fork 365
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
Invalid E.164 format for pt_PT PhoneNumber Provider #925
Comments
- Override $e164Formats in order to provide locale specific phone numbers (mobile and landline) in E.164 format. - Add constants / static properties for common formatting codes (country, area and mobile service). - Add methods 'e164MobileNumber' and 'e164LandlineNumber' to provide mobile-only and landline-only phone numbers, respectively.
This is as intended since the method is not implemented for the locale itself |
@pimjansen What do you mean, did you have a look at the PR #926? It doesn't make much sense to have a factory to create locale specific generators that register providers that don't provide locale specific data, IMO. If we look at similar issues: We can see that they report the same thing. Also, if we look at each provider PhoneNumber class ( |
- Add tests for e164PhoneNumber, e164MobileNumber and e164LandlineNumber. - Simplify regex for phoneNumber. Note: - Regex for phoneNumber was duplicating some information. It also validated for landline numbers starting at 20 even tho it wasn't present in the provider $formats. - Regex for country code, mobile number and landline number could be placed in a const variable. The problem is: there's some issues with interpolating self/static variables and concatenation would probably be hard to read.
Summary
According to PHPDoc/DockBlock, the
Generator
class should have the methode164PhoneNumber
. However, callingfake('pt_PT')->unique()->e164PhoneNumber()
(fake
is a Laravel abstraction overFaker\Factory::create
) returns numbers for multiple locales.This happens because the
pt_PT
provider (Faker\Provider\pt_PT\PhoneNumber
) doesn't override the propertye164Formats
from the base class in order to provide locale specific E.164 phone formats.I will create a PR to fix the issue.
Versions
fakerphp/faker
The text was updated successfully, but these errors were encountered: