From c0311f607f4b885cbc76cbe342310b7db6ba17a5 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Tue, 12 Nov 2013 16:35:37 +0100 Subject: [PATCH 1/3] add toAscii method to Italian Internet provider This was inspired by issue #189. Copied and adapted from French Internet provider. Even if current Person provider for Italian does not contains any accented letters, I added them anyway, for forward compatibility. The only current issue with Italian Person provider are names with accent inside, that currently are translated into invalid email, like "ld'amico@yahoo.com" --- src/Faker/Provider/it_IT/Internet.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Faker/Provider/it_IT/Internet.php b/src/Faker/Provider/it_IT/Internet.php index a0288b4a..6e87907f 100644 --- a/src/Faker/Provider/it_IT/Internet.php +++ b/src/Faker/Provider/it_IT/Internet.php @@ -6,4 +6,17 @@ class Internet extends \Faker\Provider\Internet { 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'); + + /** + * Converts Italian characters to their ASCII representation + * + * @return string + */ + private static function toAscii($string) + { + $from = array('à', 'À', 'é', 'É', 'è', 'È', 'ù', 'Ù', "'"); + $to = array('a', 'A', 'e', 'E', 'e', 'E', 'u', 'U', ''); + + return str_replace($from, $to, $string); + } } From d7a7a4fbfb69a01f8bc4af3fdcc2140561b4f54a Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Wed, 13 Nov 2013 10:16:34 +0100 Subject: [PATCH 2/3] Update Internet.php --- src/Faker/Provider/it_IT/Internet.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Faker/Provider/it_IT/Internet.php b/src/Faker/Provider/it_IT/Internet.php index 6e87907f..feb91e7f 100644 --- a/src/Faker/Provider/it_IT/Internet.php +++ b/src/Faker/Provider/it_IT/Internet.php @@ -7,6 +7,14 @@ class Internet extends \Faker\Provider\Internet 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'); + /** + * @{inheritdoc} + */ + public function userName() + { + return static::toAscii(parent::userName()); + } + /** * Converts Italian characters to their ASCII representation * From 056d6c30cadfe5527196af1c059feb82e590523c Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Tue, 19 Nov 2013 09:12:45 +0100 Subject: [PATCH 3/3] Update Internet.php --- src/Faker/Provider/it_IT/Internet.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Faker/Provider/it_IT/Internet.php b/src/Faker/Provider/it_IT/Internet.php index feb91e7f..21728ce1 100644 --- a/src/Faker/Provider/it_IT/Internet.php +++ b/src/Faker/Provider/it_IT/Internet.php @@ -12,7 +12,9 @@ class Internet extends \Faker\Provider\Internet */ public function userName() { - return static::toAscii(parent::userName()); + $format = static::randomElement(static::$userNameFormats); + + return static::toLower(static::toAscii(static::bothify($this->generator->parse($format)))); } /**