From 04052ab2219b55af33710668d332bb1d2ae217ad Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 25 Jun 2015 16:45:34 -0300 Subject: [PATCH] pt_BR: more flexibility to cellphone generation Currently a boolean is used to define if the cellphone should contain the ninth digit or not. This was extended so if an area code needs to be enforced, it can be generated externally and given to the cellphone generator, and it will create a correct number. --- src/Faker/Provider/pt_BR/PhoneNumber.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Faker/Provider/pt_BR/PhoneNumber.php b/src/Faker/Provider/pt_BR/PhoneNumber.php index c66b0096a6..bfa0fb51a0 100644 --- a/src/Faker/Provider/pt_BR/PhoneNumber.php +++ b/src/Faker/Provider/pt_BR/PhoneNumber.php @@ -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"; }