diff --git a/src/Faker/Provider/ru_RU/Internet.php b/src/Faker/Provider/ru_RU/Internet.php index 56d72d65..c8f3b996 100644 --- a/src/Faker/Provider/ru_RU/Internet.php +++ b/src/Faker/Provider/ru_RU/Internet.php @@ -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)); } }