mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-23 00:39:47 +01:00
Merge pull request #53 from blaugueux/locale
Added locale generator to Internet provider.
This commit is contained in:
commit
cc2a254a5c
@ -150,6 +150,9 @@ Each of the generator properties (like `name`, `address`, and `lorem`) are calle
|
||||
md5 // 'de99a620c50f2990e87144735cd357e7'
|
||||
sha1 // 'f08e7f04ca1a413807ebc47551a40a20a0b4de5c'
|
||||
sha256 // '0061e4c60dac5c1d82db0135a42e00c89ae3a333e7c26485321f24348c7e98a5'
|
||||
locale // en_UK
|
||||
countryCode // UK
|
||||
languageCode // en
|
||||
|
||||
### `Faker\Provider\Base`
|
||||
|
||||
|
@ -4,7 +4,9 @@ namespace Faker\Provider;
|
||||
|
||||
class Miscellaneous extends \Faker\Provider\Base
|
||||
{
|
||||
protected static $languageCode = array('cn', 'de', 'en', 'es', 'fr', 'it', 'pt', 'ru');
|
||||
|
||||
protected static $countryCode = array('CA', 'CN', 'DE', 'ES', 'FR', 'IE', 'IN', 'IT', 'MX', 'PT', 'RU', 'UK', 'US');
|
||||
/**
|
||||
* Return a boolean, true or false
|
||||
*
|
||||
@ -39,5 +41,28 @@ class Miscellaneous extends \Faker\Provider\Base
|
||||
{
|
||||
return hash('sha256', mt_rand());
|
||||
}
|
||||
|
||||
/**
|
||||
* @example 'fr_FR'
|
||||
*/
|
||||
public function locale()
|
||||
{
|
||||
return $this->languageCode() . '_' . $this->countryCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @example 'FR'
|
||||
*/
|
||||
public static function countryCode()
|
||||
{
|
||||
return static::randomElement(static::$countryCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @example 'fr'
|
||||
*/
|
||||
public static function languageCode()
|
||||
{
|
||||
return static::randomElement(static::$languageCode);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user