Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Implementation of the function that generates Brazilian area codes fixed. #1401

Merged
merged 3 commits into from
Feb 2, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Faker/Provider/pt_BR/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
protected static $cellphoneFormats = array('9####-####');

/**
* Generates a 2-digit area code not composed by zeroes.
* Pick one random entry out of an array of area codes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fan of the new description. It's a still generator function, so it should be something like

Generates a valid 2-digit area code

* @return string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the link to http://www.anatel.gov.br/legislacao/resolucoes/16-2001/383-resolucao-263 in a phpDoc @link line.

*/
public static function areaCode()
{
return static::randomDigitNotNull().static::randomDigitNotNull();
$areaCodes = array(
'11', '12', '13', '14', '15', '16', '17', '18', '19', '21', '22', '24',
'27', '28', '31', '32', '33', '34', '35', '37', '38', '41', '42', '43',
'44', '45', '46', '47', '48', '49', '51', '53', '54', '55', '61', '62',
'63', '64', '65', '66', '67', '68', '69', '71', '73', '74', '75', '77',
'79', '81', '82', '83', '84', '85', '86', '87', '88', '89', '91', '92',
'93', '94', '95', '96', '97', '98', '99'
);

return $areaCodes[array_rand($areaCodes, 1)];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Faker's randomElement() method instead (array_rand uses a low quality randomizer which doesn't support seeding).

}

/**
Expand Down