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:
parent
8b9bb44bbf
commit
1f25f9e8af
44
src/Faker/Provider/pt_BR/Internet.php
Normal file
44
src/Faker/Provider/pt_BR/Internet.php
Normal file
@ -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));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user