mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-24 09:19:50 +01:00
Fix issue with French phone numbers sometimes incorrect
This commit is contained in:
parent
bc9fb6566a
commit
9ce05970b4
@ -21,6 +21,16 @@ class Base
|
||||
return mt_rand(0, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random number between 1 and 9
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function randomDigitNotNull()
|
||||
{
|
||||
return mt_rand(1, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random number with 0 to $nbDigits digits
|
||||
*
|
||||
@ -60,13 +70,17 @@ class Base
|
||||
|
||||
/**
|
||||
* Replaces all hash sign ('#') occurrences with a random number
|
||||
* Replaces all percentage sign ('%') occurrences with a not null number
|
||||
*
|
||||
* @param string $string String that needs to bet parsed
|
||||
* @return string
|
||||
*/
|
||||
public static function numerify($string = '###')
|
||||
{
|
||||
return preg_replace_callback('/\#/', 'static::randomDigit', $string);
|
||||
$string = preg_replace_callback('/\#/', 'static::randomDigit', $string);
|
||||
$string = preg_replace_callback('/\%/', 'static::randomDigitNotNull', $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,11 +4,40 @@ namespace Faker\Provider\fr_FR;
|
||||
|
||||
class PhoneNumber extends \Faker\Provider\PhoneNumber
|
||||
{
|
||||
// Phone numbers can't start by 00, 07, or 09 in France
|
||||
// 01 is the most common prefix
|
||||
protected static $formats = array(
|
||||
'+33 (0)# ## ## ## ##',
|
||||
'+33 # ## ## ## ##',
|
||||
'0#########',
|
||||
'0# ## ## ## ##',
|
||||
'0# ## ## ## ##',
|
||||
'+33 (0)1 ## ## ## ##',
|
||||
'+33 (0)1 ## ## ## ##',
|
||||
'+33 (0)2 ## ## ## ##',
|
||||
'+33 (0)3 ## ## ## ##',
|
||||
'+33 (0)4 ## ## ## ##',
|
||||
'+33 (0)5 ## ## ## ##',
|
||||
'+33 (0)6 ## ## ## ##',
|
||||
'+33 (0)8 ## ## ## ##',
|
||||
'+33 1 ## ## ## ##',
|
||||
'+33 1 ## ## ## ##',
|
||||
'+33 2 ## ## ## ##',
|
||||
'+33 3 ## ## ## ##',
|
||||
'+33 4 ## ## ## ##',
|
||||
'+33 5 ## ## ## ##',
|
||||
'+33 6 ## ## ## ##',
|
||||
'+33 8 ## ## ## ##',
|
||||
'01########',
|
||||
'01########',
|
||||
'02########',
|
||||
'03########',
|
||||
'04########',
|
||||
'05########',
|
||||
'06########',
|
||||
'08########',
|
||||
'01 ## ## ## ##',
|
||||
'01 ## ## ## ##',
|
||||
'02 ## ## ## ##',
|
||||
'03 ## ## ## ##',
|
||||
'04 ## ## ## ##',
|
||||
'05 ## ## ## ##',
|
||||
'06 ## ## ## ##',
|
||||
'08 ## ## ## ##',
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user