1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-21 15:59:52 +01:00

Improvements for Russian internet provider

This commit is contained in:
ruden 2013-11-01 17:33:09 +02:00
parent 015a057797
commit 872d21c62d

View File

@ -4,8 +4,22 @@ namespace Faker\Provider\ru_RU;
class Internet extends \Faker\Provider\Internet
{
protected static $freeEmailDomain = array('yandex.ru', 'ya.ru', 'narod.ru', 'gmail.com', 'mail.ru', 'list.ru', 'bk.ru', 'inbox.ru', 'rambler.ru', 'hotmail.com');
protected static $tld = array('com', 'com', 'net', 'org', 'ru', 'ru', 'ru', 'ru');
/**
* Converts Russian characters to their ASCII representation
*
* @return string
*/
private static function toAscii($string)
{
$from = array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', 'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я');
$to = array('a', 'b', 'v', 'g', 'd', 'e', 'e', 'gh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'ch', 'sh', 'sch', '', 'y', '', 'e', 'yu', 'ya', 'a', 'b', 'v', 'g', 'd', 'e', 'e', 'gh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'ch', 'sh', 'sch', '', 'y', '', 'e', 'yu', 'ya');
return str_replace($from, $to, $string);
}
/**
* @example 'jdoe'
*/
@ -13,7 +27,7 @@ class Internet extends \Faker\Provider\Internet
{
$format = static::randomElement(static::$userNameFormats);
return static::bothify($this->generator->parse($format));
return static::toLower(static::toAscii(static::bothify($this->generator->parse($format))));
}
/**
@ -24,8 +38,8 @@ class Internet extends \Faker\Provider\Internet
$company = $this->generator->format('company');
$companyElements = explode(' ', $company);
$company = $companyElements[0];
$company = preg_replace('/,/u', '', $company);
$company = preg_replace('/\W/u', '', $company);
return $company;
return static::toLower(static::toAscii($company));
}
}