Skip to content

Commit

Permalink
Implementation of the function that generates Brazilian area codes fi…
Browse files Browse the repository at this point in the history
…xed. (fzaninotto#1401)

* Fixing the implementation of the function that generates Brazilian area codes

* Fixing a problem with random element picking in the function areaCode at pt_BR/PhoneNumber.php class

* Improving the areaCode() function documentation and changing the way of how the area code is generated
  • Loading branch information
jackmiras authored and fzaninotto committed Feb 2, 2018
1 parent e8afe1e commit 6f37421
Showing 1 changed file with 11 additions and 2 deletions.
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 @@ -4,7 +4,6 @@

class PhoneNumber extends \Faker\Provider\PhoneNumber
{

protected static $landlineFormats = array('2###-####', '3###-####', '4###-####');

/**
Expand All @@ -15,11 +14,21 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber

/**
* Generates a 2-digit area code not composed by zeroes.
* @link http://www.anatel.gov.br/legislacao/resolucoes/16-2001/383-resolucao-263.
* @return string
*/
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 self::randomElement($areaCodes);
}

/**
Expand Down

0 comments on commit 6f37421

Please sign in to comment.