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

Commit

Permalink
Merge pull request #497 from stelgenhof/master
Browse files Browse the repository at this point in the history
Created faker for Currency Codes.
  • Loading branch information
fzaninotto committed Jan 12, 2015
2 parents 9d9bd78 + 9596460 commit 1dc843a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Faker/Provider/Miscellaneous.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,30 @@ class Miscellaneous extends \Faker\Provider\Base
'zh_MO', 'zh_SG', 'zh_TW', 'zu_ZA',
);

/**
* @link http://en.wikipedia.org/wiki/ISO_4217
* On date of 2015-01-10
*/
protected static $currencyCode = array(
'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN',
'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL',
'BSD', 'BTC', 'BTN', 'BWP', 'BYR', 'BZD', 'CAD', 'CDF', 'CHF', 'CLF',
'CLP', 'CNY', 'COP', 'CRC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP',
'DZD', 'EEK', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL',
'GGP', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK',
'HTG', 'HUF', 'IDR', 'ILS', 'IMP', 'INR', 'IQD', 'IRR', 'ISK', 'JEP',
'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD',
'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD',
'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MTL', 'MUR',
'MVR', 'MWK', 'MXN', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR',
'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR',
'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD',
'SHP', 'SLL', 'SOS', 'SRD', 'STD', 'SVC', 'SYP', 'SZL', 'THB', 'TJS',
'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD',
'UYU', 'UZS', 'VEF', 'VND', 'VUV', 'WST', 'XAF', 'XAG', 'XAU', 'XCD',
'XDR', 'XOF', 'XPF', 'YER', 'ZAR', 'ZMK', 'ZMW', 'ZWL'
);

/**
* Return a boolean, true or false
*
Expand Down Expand Up @@ -221,4 +245,13 @@ public static function languageCode()
{
return static::randomElement(static::$languageCode);
}

/**
* @example 'EUR'
* @link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
*/
public static function currencyCode()
{
return static::randomElement(static::$currencyCode);
}
}
5 changes: 5 additions & 0 deletions test/Faker/Provider/MiscellaneousTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public function testLanguage()
{
$this->assertRegExp('/^[a-z]{2}$/', Miscellaneous::languageCode());
}

public function testCurrencyCode()
{
$this->assertRegExp('/^[A-Z]{3}$/', Miscellaneous::currencyCode());
}
}

0 comments on commit 1dc843a

Please sign in to comment.