1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-21 07:49:53 +01:00

Updated toAscii es_ES provider function

This commit is contained in:
Lito 2013-10-22 16:40:43 +02:00
parent f61bf615bb
commit 0cdc875aed

View File

@ -15,10 +15,10 @@ class Internet extends \Faker\Provider\Internet
*/
private static function toAscii($string)
{
$string = htmlentities($string, ENT_NOQUOTES, 'UTF-8');
$string = preg_replace('/\W/', '-', preg_replace('/&(\w)\w+;/', '$1', $string));
$from = array('á', 'Á', 'é', 'É', 'í', 'Í', 'ó', 'Ó', 'ú', 'Ú', 'ü', 'Ü', 'ñ', ');
$to = array('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U', 'u', 'U', 'n', 'N');
return trim($string, '-');
return str_replace($from, $to, $string);
}
/**
@ -39,6 +39,6 @@ class Internet extends \Faker\Provider\Internet
{
list($company) = explode(' ', $this->generator->format('company'));
return static::toLower(static::toAscii($company));
return static::toLower(static::toAscii(preg_replace('/\W/u', '', $company)));
}
}