From c0311f607f4b885cbc76cbe342310b7db6ba17a5 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Tue, 12 Nov 2013 16:35:37 +0100 Subject: [PATCH] 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); + } }