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

Merge pull request #194 from eusonlito/master

Added Internet strings generation to es_ES provider
This commit is contained in:
Francois Zaninotto 2013-11-18 12:50:44 -08:00
commit c12caeadb2

View File

@ -0,0 +1,44 @@
<?php
namespace Faker\Provider\es_ES;
class Internet extends \Faker\Provider\Internet
{
protected static $freeEmailDomain = array('gmail.com', 'hotmail.com', 'hotmail.es', 'yahoo.com', 'yahoo.es', 'live.com', 'hispavista.com', 'latinmail.com', 'terra.com');
protected static $tld = array('com', 'com', 'com', 'com', 'net', 'org', 'org', 'es', 'es', 'es', 'com.es');
/**
* Converts Spanish characters to their ASCII representation using an standard
* chars convert function
*
* @return string
*/
private static function toAscii($string)
{
$from = array('á', 'Á', 'é', 'É', 'í', 'Í', 'ó', 'Ó', 'ú', 'Ú', 'ü', 'Ü', 'ñ', 'Ñ');
$to = array('a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U', 'u', 'U', 'n', 'N');
return str_replace($from, $to, $string);
}
/**
* @example 'alex.iglesias'
*/
public function userName()
{
$format = static::randomElement(static::$userNameFormats);
$user = static::bothify($this->generator->parse($format));
return str_replace('-', '.', static::toLower(static::toAscii($user)));
}
/**
* @example 'lovato-exposito'
*/
public function domainWord()
{
list($company) = explode(' ', $this->generator->format('company'));
return static::toLower(static::toAscii(preg_replace('/\W/u', '', $company)));
}
}