diff --git a/src/Faker/Provider/pt_PT/PhoneNumber.php b/src/Faker/Provider/pt_PT/PhoneNumber.php index f85f3901..dcb5af02 100644 --- a/src/Faker/Provider/pt_PT/PhoneNumber.php +++ b/src/Faker/Provider/pt_PT/PhoneNumber.php @@ -7,81 +7,44 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber /* * @link http://en.wikipedia.org/wiki/Telephone_numbers_in_Portugal */ - protected static $phoneNumberPrefixes = array( - 'Abrantes' => '241', - 'Angra do Heroísmo' => '295', - 'Arganil' => '235', - 'Aveiro' => '234', - 'Beja' => '284', - 'Braga' => '253', - 'Bragança' => '273', - 'Caldas da Rainha' => '262', - 'Castelo Branco' => '272', - 'Castro Verde' => '286', - 'Chaves' => '276', - 'Coimbra' => '239', - 'Covilhã' => '275', - 'Estremoz' => '268', - 'Évora' => '266', - 'Faro' => '289', - 'Figueira da Foz' => '233', - 'Funchal' => '291', - 'Guarda' => '271', - 'Horta' => '292', - 'Idanha-a-Nova' => '277', - 'Leiria' => '244', - 'Lisboa' => '21#', - 'Mealhada' => '231', - 'Mirandela' => '278', - 'Moncorvo' => '279', - 'Moura' => '285', - 'Odemira' => '283', - 'Penafiel' => '255', - 'Peso da Régua' => '254', - 'Pombal' => '236', - 'Ponta Delgada' => '296', - 'Ponte de Sôr' => '242', - 'Portalegre' => '245', - 'Portimão' => '282', - 'Porto' => '22#', - 'Proença-a-Nova' => '274', - 'S. João da Madeira' => '256', - 'Santarém' => '243', - 'Santiago do Cacém' => '269', - 'Seia' => '238', - 'Setúbal' => '265', - 'Tavira' => '281', - 'Torres Novas' => '249', - 'Torres Vedras' => '261', - 'Valença' => '251', - 'Viana do Castelo' => '258', - 'Vila Franca de Xira' => '263', - 'V. N. de Famalicão' => '252', - 'Vila Real' => '259', - 'Viseu' => '232', + protected static $formats = array( + '+351 91#########', + '+351 92#########', + '+351 93#########', + '+351 96#########', + '+351 21#########', + '+351 22#########', + '+351 23#########', + '+351 24#########', + '+351 25#########', + '+351 26#########', + '+351 27#########', + '+351 28#########', + '+351 29#########', + '91#########', + '92#########', + '93#########', + '96#########', + '21#########', + '22#########', + '23#########', + '24#########', + '25#########', + '26#########', + '27#########', + '28#########', + '29#########', ); protected static $mobileNumberPrefixes = array( - '91#', - '92#', - '93#', - '96#', + '91', + '92', + '93', + '96', ); - protected static $countryCode = '+351'; - - public static function phoneNumber() - { - $elements = array_merge(static::$phoneNumberPrefixes, static::$mobileNumberPrefixes); - $format = static::randomElement($elements).'######'; - - return static::numerify(static::randomElement(array(static::$countryCode, '')).$format); - } - public static function mobileNumber() { - $format = static::randomElement(static::$mobileNumberPrefixes).'######'; - - return static::numerify(static::randomElement(array(static::$countryCode, '')).$format); + return static::numerify(static::randomElement(static::$mobileNumberPrefixes).'#######'); } } diff --git a/test/Faker/Provider/pt_PT/PhoneNumberTest.php b/test/Faker/Provider/pt_PT/PhoneNumberTest.php index 1ae51c90..04b2f63d 100644 --- a/test/Faker/Provider/pt_PT/PhoneNumberTest.php +++ b/test/Faker/Provider/pt_PT/PhoneNumberTest.php @@ -16,10 +16,10 @@ class PhoneNumberTest extends \PHPUnit_Framework_TestCase public function testPhoneNumberReturnsPhoneNumberWithOrWithoutPrefix() { - $this->assertRegExp('/^(9[1,2,3,6][0-9]{7})|(2[0-9]{8})|(\+351[2][0-9]{8})|(\+3519[1,2,3,6][0-9]{7})/', $this->faker->phoneNumber()); + $this->assertRegExp('/^(9[1,2,3,6][0-9]{7})|(2[0-9]{8})|(\+351 [2][0-9]{8})|(\+351 9[1,2,3,6][0-9]{7})/', $this->faker->phoneNumber()); } public function testMobileNumberReturnsMobileNumberWithOrWithoutPrefix() { - $this->assertRegExp('/^(9[1,2,3,6][0-9]{7})|(\+3519[1,2,3,6][0-9]{7})/', $this->faker->mobileNumber()); + $this->assertRegExp('/^(9[1,2,3,6][0-9]{7})/', $this->faker->mobileNumber()); } }