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

pt_BR: more flexibility to cellphone generation #623

Merged
Merged
Changes from all 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
8 changes: 4 additions & 4 deletions src/Faker/Provider/pt_BR/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public static function areaCode()
/**
* Generates a 8/9-digit cellphone number without formatting characters.
* @param bool $formatted [def: true] If it should return a formatted number or not.
* @param bool $ninth [def: false] If the number should have a nine in the beginning or not.
* If the generated number begins with 7 this is ignored.
* @param int|bool $area [def: false] A specific area code to which the number will belong.
* If a boolean is used, will add (or not) the ninth digit.
* @return string
*/
public static function cellphone($formatted = true, $ninth = false)
public static function cellphone($formatted = true, $area = false)
{
$number = static::numerify(static::randomElement(static::$cellphoneFormats));

if ($ninth && $number[0] != 7) {
if ($area === true || in_array($area, static::$ninthDigitAreaCodes)) {
$number = "9$number";
}

Expand Down