Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Add region and region abbreviation methods #828

Merged
merged 3 commits into from
Feb 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,18 @@ echo $faker->taxpayerIdentificationNumber; // '165249277'

```

### `Faker\Provider\pt_BR\Address`

```php
<?php

// Generates a random region name
echo $faker->region; // 'Nordeste'

// Generates a random region abbreviation
echo $faker->regionAbbr; // 'NE'
```

### `Faker\Provider\pt_BR\PhoneNumber`

```php
Expand Down
22 changes: 22 additions & 0 deletions src/Faker/Provider/pt_BR/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class Address extends \Faker\Provider\Address
'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ', 'RN', 'RS', 'RO', 'RR', 'SC',
'SP', 'SE', 'TO'
);
protected static $region = array(
'Centro-Oeste', 'Nordeste', 'Norte', 'Sudeste', 'Sul'
);
protected static $regionAbbr = array(
'CO', 'N', 'NE', 'SE', 'S'
);
protected static $country = array(
'Afeganistão', 'África do Sul', 'Albânia', 'Alemanha', 'Andorra',
'Angola', 'Antigua e Barbuda', 'Arabia Saudita', 'Argélia',
Expand Down Expand Up @@ -129,4 +135,20 @@ public static function stateAbbr()
{
return static::randomElement(static::$stateAbbr);
}

/**
* @example 'Nordeste'
*/
public static function region()
{
return static::randomElement(static::$region);
}

/**
* @example 'NE'
*/
public static function regionAbbr()
{
return static::randomElement(static::$regionAbbr);
}
}