mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-22 00:09:59 +01:00
Fix issues with non-ascii characters in emails
This commit is contained in:
parent
5cc1162da1
commit
b5859dc870
@ -7,4 +7,27 @@ class Internet extends \Faker\Provider\Internet
|
||||
protected static $safeEmailTld = array('org', 'com', 'net', 'bg');
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com', 'mail.bg', 'abv.bg', 'dir.bg');
|
||||
protected static $tld = array('bg', 'bg', 'bg', 'bg', 'bg', 'bg', 'com', 'biz', 'info', 'net', 'org');
|
||||
|
||||
/**
|
||||
* @example 'jdoe'
|
||||
*/
|
||||
public function userName()
|
||||
{
|
||||
$format = static::randomElement(static::$userNameFormats);
|
||||
return static::bothify($this->generator->parse($format));
|
||||
}
|
||||
|
||||
/**
|
||||
* @example 'faber'
|
||||
*/
|
||||
public function domainWord()
|
||||
{
|
||||
$company = $this->generator->format('company');
|
||||
$companyElements = explode(' ', $company);
|
||||
$company = $companyElements[0];
|
||||
$company = preg_replace('/\W/', '', $company);
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,8 +83,7 @@ class Person extends \Faker\Provider\Person
|
||||
|
||||
public static function firstName()
|
||||
{
|
||||
$gender = static::randomElement(array('Male', 'Female'));
|
||||
return call_user_func(array('static', 'firstName'.$gender));
|
||||
return mt_rand(1, 100) <= 50 ? static::firstNameMale() : static::firstNameFemale();
|
||||
}
|
||||
|
||||
public static function firstNameMale()
|
||||
@ -99,8 +98,7 @@ class Person extends \Faker\Provider\Person
|
||||
|
||||
public static function lastName()
|
||||
{
|
||||
$gender = static::randomElement(array('Male', 'Female'));
|
||||
return call_user_func(array('static', 'lastName'.$gender));
|
||||
return mt_rand(1, 100) <= 50 ? static::lastNameMale() : static::lastNameFemale();
|
||||
}
|
||||
|
||||
public static function lastNameMale()
|
||||
|
47
src/Faker/Provider/fr_FR/Internet.php
Normal file
47
src/Faker/Provider/fr_FR/Internet.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Provider\fr_FR;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('com', 'net', 'fr', 'fr');
|
||||
protected static $freeEmailDomain = array('voila.fr', 'gmail.com', 'hotmail.fr', 'yahoo.fr', 'laposte.net', 'free.fr', 'sfr.fr', 'orange.fr', 'bouygtel.fr', 'club-internet.fr', 'dbmail.com', 'live.com', 'ifrance.com', 'noos.fr', 'tele2.fr', 'tiscali.fr', 'wanadoo.fr');
|
||||
protected static $tld = array('com', 'com', 'com', 'net', 'org', 'fr', 'fr', 'fr');
|
||||
|
||||
/**
|
||||
* Converts French characters to their ASCII representation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function toAscii($string)
|
||||
{
|
||||
$from = array('à', 'À', 'ç', 'Ç', 'é', 'É', 'è', 'È', 'ë', 'Ë', 'ï', 'Ï', 'î', 'Î', 'ô', 'Ô', 'ù', 'Ù');
|
||||
$to = array('a', 'A', 'c', 'c', 'e', 'E', 'e', 'E', 'e', 'E', 'i', 'I', 'i', 'I', 'o', 'O', 'u', 'U');
|
||||
|
||||
return str_replace($from, $to, $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example 'jdoe'
|
||||
*/
|
||||
public function userName()
|
||||
{
|
||||
$format = static::randomElement(static::$userNameFormats);
|
||||
return strtolower(static::toAscii(static::bothify($this->generator->parse($format))));
|
||||
}
|
||||
|
||||
/**
|
||||
* @example 'faber'
|
||||
*/
|
||||
public function domainWord()
|
||||
{
|
||||
$company = $this->generator->format('company');
|
||||
$companyElements = explode(' ', $company);
|
||||
$company = $companyElements[0];
|
||||
$company = preg_replace('/\W/', '', $company);
|
||||
|
||||
return strtolower(static::toAscii($company));
|
||||
}
|
||||
|
||||
|
||||
}
|
14
src/Faker/Provider/fr_FR/PhoneNumber.php
Normal file
14
src/Faker/Provider/fr_FR/PhoneNumber.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Provider\fr_FR;
|
||||
|
||||
class PhoneNumber extends \Faker\Provider\PhoneNumber
|
||||
{
|
||||
protected static $formats = array(
|
||||
'+33 (0)# ## ## ## ##',
|
||||
'+33 # ## ## ## ##',
|
||||
'0#########',
|
||||
'0# ## ## ## ##',
|
||||
'0# ## ## ## ##',
|
||||
);
|
||||
}
|
31
src/Faker/Provider/ru_RU/Internet.php
Normal file
31
src/Faker/Provider/ru_RU/Internet.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Provider\ru_RU;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $tld = array('com', 'com', 'net', 'org', 'ru', 'ru', 'ru', 'ru');
|
||||
|
||||
/**
|
||||
* @example 'jdoe'
|
||||
*/
|
||||
public function userName()
|
||||
{
|
||||
$format = static::randomElement(static::$userNameFormats);
|
||||
return static::bothify($this->generator->parse($format));
|
||||
}
|
||||
|
||||
/**
|
||||
* @example 'faber'
|
||||
*/
|
||||
public function domainWord()
|
||||
{
|
||||
$company = $this->generator->format('company');
|
||||
$companyElements = explode(' ', $company);
|
||||
$company = $companyElements[0];
|
||||
$company = preg_replace('/,/', '', $company);
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user