mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-22 00:09:59 +01:00
Make safeEmail really safe
This commit is contained in:
parent
d2bd914407
commit
30e7cd6796
@ -4,7 +4,6 @@ namespace Faker\Provider;
|
||||
|
||||
class Internet extends \Faker\Provider\Base
|
||||
{
|
||||
protected static $safeEmailTld = array('org', 'com', 'net');
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com');
|
||||
protected static $tld = array('com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org');
|
||||
|
||||
@ -36,9 +35,9 @@ class Internet extends \Faker\Provider\Base
|
||||
/**
|
||||
* @example 'jdoe@example.com'
|
||||
*/
|
||||
public function safeEmail()
|
||||
public final function safeEmail()
|
||||
{
|
||||
return preg_replace('/\s/', '', $this->userName() . '@' . static::safeEmailDomain());
|
||||
return preg_replace('/\s/', '', $this->userName() . '@' . $this->safeEmailDomain());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,10 +66,25 @@ class Internet extends \Faker\Provider\Base
|
||||
|
||||
/**
|
||||
* @example 'example.org'
|
||||
* @param boolean $knownTLD If set to true only domains with a well known TLD (i.e. com, org and net) are returned.
|
||||
*/
|
||||
public static function safeEmailDomain()
|
||||
public final function safeEmailDomain($knownTLD = false)
|
||||
{
|
||||
return 'example.' . static::randomElement(static::$safeEmailTld);
|
||||
$domains = array(
|
||||
'example.com',
|
||||
'example.org',
|
||||
'example.net'
|
||||
);
|
||||
if (!$knownTLD) {
|
||||
$domains[] = '*.example';
|
||||
$domains[] = '*.test';
|
||||
$domains[] = '*.invalid';
|
||||
$domains[] = '*.lan';
|
||||
}
|
||||
|
||||
$domain = static::randomElement($domains);
|
||||
|
||||
return str_replace('*', $this->domainWord(), $domain);
|
||||
}
|
||||
/**
|
||||
* @example 'jdoe'
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\bg_BG;
|
||||
|
||||
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');
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\cs_CZ;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('com', 'cz');
|
||||
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'seznam.cz', 'atlas.cz', 'centrum.cz', 'email.cz', 'post.cz');
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\de_DE;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('com', 'net', 'de', 'de');
|
||||
protected static $freeEmailDomain = array('web.de', 'gmail.com', 'hotmail.de', 'yahoo.de', 'googlemail.com', 'aol.de', 'gmx.de');
|
||||
protected static $tld = array('com', 'com', 'com', 'net', 'org', 'de', 'de', 'de');
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\en_GB;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('org', 'com', 'net', 'co.uk');
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com', 'gmail.co.uk', 'yahoo.co.uk', 'hotmail.co.uk');
|
||||
protected static $tld = array('com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org', 'co.uk');
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\fi_FI;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('org', 'com', 'net', 'fi');
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com', 'jippii.fi', 'luukku.com');
|
||||
protected static $tld = array('com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org', 'fi');
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ 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');
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\it_IT;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('org', 'com', 'net', 'it');
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com', 'email.it', 'libero.it', 'yahoo.it');
|
||||
protected static $tld = array('com', 'com', 'com', 'net', 'org', 'it', 'it', 'it');
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\nl_BE;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('com', 'net', 'be', 'be');
|
||||
protected static $freeEmailDomain = array('gmail.com', 'hotmail.com', 'yahoo.com', 'advalvas.be');
|
||||
protected static $tld = array('com', 'com', 'com', 'net', 'org', 'be', 'be', 'be');
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\nl_NL;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('com', 'net', 'nl', 'nl');
|
||||
protected static $freeEmailDomain = array('gmail.com', 'hotmail.nl', 'live.nl', 'yahoo.nl');
|
||||
protected static $tld = array('com', 'com', 'com', 'net', 'org', 'nl', 'nl', 'nl');
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\pl_PL;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('com', 'pl');
|
||||
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'wp.pl', 'onet.pl', 'interia.pl', 'gazeta.pl');
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace Faker\Provider\sk_SK;
|
||||
|
||||
class Internet extends \Faker\Provider\Internet
|
||||
{
|
||||
protected static $safeEmailTld = array('com', 'sk');
|
||||
|
||||
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'zoznam.sk', 'atlas.', 'centrum.sk', 'azet.sk', 'post.sk');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user