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

[pt_BR] Created Internet provider with brazilian domains, top-level domains and transliteration method.

This commit is contained in:
Pedro Junior 2013-07-08 21:51:41 -03:00
parent 8b9bb44bbf
commit 1f25f9e8af

@ -0,0 +1,44 @@
<?php
namespace Faker\Provider\pt_BR;
class Internet extends \Faker\Provider\Internet
{
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com', 'uol.com.br', 'terra.com.br', 'ig.com.br');
protected static $tld = array('com', 'com', 'com.br', 'com.br', 'net', 'net.br', 'br', 'org');
/**
* Converts pt-BR characters to their ASCII representation
*
* @param string $string
* @return string
*/
private static function toAscii($string)
{
return preg_replace('/&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/i', '$1',
htmlentities($string, ENT_QUOTES, 'UTF-8'));
}
/**
* @example 'jdoe'
*/
public function userName()
{
$format = static::randomElement(static::$userNameFormats);
return static::toLower(static::toAscii(static::bothify($this->generator->parse($format))));
}
/**
* @example 'faber'
*/
public function domainWord()
{
$company = $this->generator->format('company');
$companyElements = explode(' ', $company);
$company = $companyElements[0];
$company = preg_replace('/\W/u', '', $company);
return static::toLower(static::toAscii($company));
}
}