From 984bd97865d9cf01dc257e68a1496e89b939386c Mon Sep 17 00:00:00 2001 From: Gilles Doge Date: Mon, 8 Sep 2014 15:31:03 +0200 Subject: [PATCH] added Country ISO 3166-1 alpha-3 code --- src/Faker/Provider/Miscellaneous.php | 10 ++++++++++ test/Faker/Provider/MiscellaneousTest.php | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/Faker/Provider/Miscellaneous.php b/src/Faker/Provider/Miscellaneous.php index f240f56cb7..550f825b0c 100644 --- a/src/Faker/Provider/Miscellaneous.php +++ b/src/Faker/Provider/Miscellaneous.php @@ -8,6 +8,8 @@ class Miscellaneous extends \Faker\Provider\Base protected static $countryCode = array('CA', 'CN', 'DE', 'ES', 'FR', 'IE', 'IN', 'IT', 'MX', 'PT', 'RU', 'GB', 'US'); + protected static $countryISOAlpha3 = array('CAN', 'CHN', 'DEU', 'ESP', 'FRA', 'IRL', 'IND', 'ITA', 'MEX', 'PRT', 'RUS', 'GBR', 'USA'); + protected static $localeData = array( 'aa_DJ', 'aa_ER', 'aa_ET', 'af_NA', 'af_ZA', 'ak_GH', @@ -142,6 +144,14 @@ public static function countryCode() return static::randomElement(static::$countryCode); } + /** + * @example 'FRA' + */ + public static function countryISOAlpha3() + { + return static::randomElement(static::$countryISOAlpha3); + } + /** * @example 'fr' */ diff --git a/test/Faker/Provider/MiscellaneousTest.php b/test/Faker/Provider/MiscellaneousTest.php index 779583759f..5de85eaeae 100644 --- a/test/Faker/Provider/MiscellaneousTest.php +++ b/test/Faker/Provider/MiscellaneousTest.php @@ -37,6 +37,11 @@ public function testCountryCode() $this->assertRegExp('/^[A-Z]{2}$/', Miscellaneous::countryCode()); } + public function testCountryISOAlpha3() + { + $this->assertRegExp('/^[A-Z]{3}$/', Miscellaneous::countryISOAlpha3()); + } + public function testLanguage() { $this->assertRegExp('/^[a-z]{2}$/', Miscellaneous::languageCode());