This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from JasonMortonNZ/master
NEW - Added NZ localisation
- Loading branch information
Showing
4 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Faker\Provider\en_NZ; | ||
|
||
class Address extends \Faker\Provider\Address | ||
{ | ||
|
||
/** | ||
* An array of en_NZ (New Zealand) building number formats | ||
* @var array | ||
*/ | ||
protected static $buildingNumber = array('#', '##', '###'); | ||
|
||
/** | ||
* An array of en_NZ (New Zealand) street suffixes | ||
* @var array | ||
*/ | ||
protected static $streetSuffix = array( | ||
'Avenue', 'Close', 'Court', 'Crescent', 'Drive', 'Esplanade', 'Grove', 'Heights', 'Highway', 'Hill', 'Lane', 'Line', 'Mall', 'Parade', 'Place', 'Quay', 'Rise', 'Road', 'Square', 'Street', 'Terrace', 'Way' | ||
); | ||
|
||
/** | ||
* City suffixes | ||
* @var array | ||
*/ | ||
protected static $citySuffix = array('ville', 'ston'); | ||
|
||
/** | ||
* City formats | ||
* @var array | ||
*/ | ||
protected static $cityFormats = array('{{firstName}}{{citySuffix}}'); | ||
|
||
/** | ||
* An array of en_NZ (New Zealand) regions | ||
* @see http://en.wikipedia.org/wiki/Regions_of_New_Zealand | ||
* @var array | ||
*/ | ||
protected static $region = array( | ||
'Auckland', 'Bay of Plenty', 'Canterbury', 'Gisborne', 'Hawkes Bay', 'Manawatu-Whanganui', 'Marlborough', 'Nelson', 'Northland', 'Otago', 'Southland', 'Taranaki', 'Tasman', 'Waikato', 'Wellington', 'West Coast' | ||
); | ||
|
||
/** | ||
* An array of en_NZ (New Zealand) poscode formats | ||
* @var array | ||
*/ | ||
protected static $postcode = array('####'); | ||
|
||
/** | ||
* An array of en_NZ (New Zealand) countries | ||
* @var array | ||
*/ | ||
protected static $country = array('New Zealand'); | ||
|
||
/** | ||
* An array of en_NZ (New Zealand) address formats | ||
* @var array | ||
*/ | ||
protected static $addressFormats = array('{{buildingNumber}} {{streetName}}, {{city}}, {{region}}, {{postcode}}'); | ||
|
||
/** | ||
* An array of en_NZ (New Zealand) street address formats | ||
* @var array | ||
*/ | ||
protected static $streetAddressFormats = array('{{buildingNumber}} {{streetName}}'); | ||
|
||
/** | ||
* Return a en_NZ (New Zealand) postcode | ||
* @return string | ||
*/ | ||
public static function postcode() | ||
{ | ||
return static::numerify(static::randomElement(static::$postcode)); | ||
} | ||
|
||
/** | ||
* Return a en_NZ (New Zealand) region | ||
* @return string | ||
*/ | ||
public static function region() | ||
{ | ||
return static::randomElement(static::$region); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Faker\Provider\en_NZ; | ||
|
||
class Internet extends \Faker\Provider\Internet | ||
{ | ||
/** | ||
* An array of common en_NZ (New Zeland) TLD's | ||
* @var array | ||
*/ | ||
protected static $tld = array( | ||
'com', 'co.nz', 'ac.nz', 'geek.nz', 'gen.nz', 'kiwi.nz', 'maori.nz', 'net.nz', 'org.nz', 'school.nz', 'govt.nz', 'iwi.nz', 'mil.nz', 'health.nz', 'parliment.nz' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
namespace Faker\Provider\en_NZ; | ||
|
||
class PhoneNumber extends \Faker\Provider\PhoneNumber | ||
{ | ||
/** | ||
* An array of en_NZ landline phone number formats | ||
* @var array | ||
*/ | ||
protected static $formats = array( | ||
// National Calls | ||
'{{area_code}}{{beginning_number}}######', | ||
'{{area_code}} {{beginning_number}}## ####' | ||
); | ||
|
||
/** | ||
* An array of en_NZ mobile (cell) phone number formats | ||
* @var array | ||
*/ | ||
protected static $mobileFormats = array( | ||
// Local | ||
'02########', | ||
'02#########', | ||
'02# ### ####', | ||
'02# #### ####' | ||
); | ||
|
||
/** | ||
* An array of toll free phone number formats | ||
* @var array | ||
*/ | ||
protected static $tollFreeFormats = array( | ||
'0508######', | ||
'0508 ######', | ||
'0508 ### ###', | ||
'0800######', | ||
'0800 ######', | ||
'0800 ### ###', | ||
); | ||
|
||
/** | ||
* An array of en_NZ landline area codes | ||
* @var array | ||
*/ | ||
protected static $areaCodes = array( | ||
'02', '03', '04', '06', '07', '09' | ||
); | ||
|
||
/** | ||
* An array of en_NZ landline beginning numbers | ||
* @var array | ||
*/ | ||
protected static $beginningNumbers = array( | ||
'2', '3', '4', '5', '6', '7', '8', '9' | ||
); | ||
|
||
/** | ||
* Return a en_NZ landline phone number | ||
* @return string | ||
*/ | ||
public static function phoneNumber() | ||
{ | ||
$format = static::numerify(static::randomElement(static::$formats)); | ||
|
||
$withAreaCode = str_replace('{{area_code}}', static::areaCode(), $format); | ||
|
||
return str_replace('{{beginning_number}}', static::beginningNumber(), $withAreaCode); | ||
} | ||
|
||
/** | ||
* Return a en_NZ mobile phone number | ||
* @return string | ||
*/ | ||
public static function mobileNumber() | ||
{ | ||
return static::numerify(static::randomElement(static::$mobileFormats)); | ||
} | ||
|
||
/** | ||
* Return a en_NZ cell (mobile) phone number | ||
* @return string | ||
*/ | ||
public static function cellNumber() | ||
{ | ||
return static::mobileNumber(); | ||
} | ||
|
||
/** | ||
* Return a en_NZ toll free phone number | ||
* @return string | ||
*/ | ||
public static function tollFreeNumber() | ||
{ | ||
return static::numerify(static::randomElement(static::$tollFreeFormats)); | ||
} | ||
|
||
/** | ||
* Return a en_NZ landline area code | ||
* @return string | ||
*/ | ||
public static function areaCode() | ||
{ | ||
return static::numerify(static::randomElement(static::$areaCodes)); | ||
} | ||
|
||
/** | ||
* Return a en_NZ landline beginning number | ||
* @return string | ||
*/ | ||
public static function beginningNumber() | ||
{ | ||
return static::numerify(static::randomElement(static::$beginningNumbers)); | ||
} | ||
} |