PageRenderTime 42ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Faker/Provider/Miscellaneous.php

https://github.com/JhonnyL/Faker
PHP | 151 lines | 117 code | 10 blank | 24 comment | 0 complexity | 75bf063b7a5f2e6fc65db45121ff556e MD5 | raw file
  1. <?php
  2. namespace Faker\Provider;
  3. class Miscellaneous extends \Faker\Provider\Base
  4. {
  5. protected static $languageCode = array('cn', 'de', 'en', 'es', 'fr', 'it', 'pt', 'ru');
  6. protected static $countryCode = array('CA', 'CN', 'DE', 'ES', 'FR', 'IE', 'IN', 'IT', 'MX', 'PT', 'RU', 'UK', 'US');
  7. protected static $localeData = array(
  8. 'aa_DJ', 'aa_ER', 'aa_ET',
  9. 'af_NA', 'af_ZA', 'ak_GH',
  10. 'am_ET', 'ar_AE', 'ar_BH', 'ar_DZ',
  11. 'ar_EG', 'ar_IQ', 'ar_JO', 'ar_KW', 'ar_LB',
  12. 'ar_LY', 'ar_MA', 'ar_OM', 'ar_QA', 'ar_SA',
  13. 'ar_SD', 'ar_SY', 'ar_TN', 'ar_YE',
  14. 'as_IN', 'az_AZ', 'be_BY',
  15. 'bg_BG', 'bn_BD', 'bn_IN',
  16. 'bo_CN', 'bo_IN', 'bs_BA',
  17. 'byn_ER', 'ca_ES',
  18. 'cch_NG', 'cs_CZ',
  19. 'cy_GB', 'da_DK', 'de_AT',
  20. 'de_BE', 'de_CH', 'de_DE', 'de_LI', 'de_LU',
  21. 'dv_MV', 'dz_BT',
  22. 'ee_GH', 'ee_TG', 'el_CY', 'el_GR',
  23. 'en_AS', 'en_AU', 'en_BE', 'en_BW',
  24. 'en_BZ', 'en_CA', 'en_GB', 'en_GU', 'en_HK',
  25. 'en_IE', 'en_IN', 'en_JM', 'en_MH', 'en_MP',
  26. 'en_MT', 'en_NA', 'en_NZ', 'en_PH', 'en_PK',
  27. 'en_SG', 'en_TT', 'en_UM', 'en_US', 'en_VI',
  28. 'en_ZA', 'en_ZW', 'es_AR',
  29. 'es_BO', 'es_CL', 'es_CO', 'es_CR', 'es_DO',
  30. 'es_EC', 'es_ES', 'es_GT', 'es_HN', 'es_MX',
  31. 'es_NI', 'es_PA', 'es_PE', 'es_PR', 'es_PY',
  32. 'es_SV', 'es_US', 'es_UY', 'es_VE',
  33. 'et_EE', 'eu_ES', 'fa_AF',
  34. 'fa_IR', 'fi_FI', 'fil_PH',
  35. 'fo_FO', 'fr_BE', 'fr_CA',
  36. 'fr_CH', 'fr_FR', 'fr_LU', 'fr_MC', 'fr_SN',
  37. 'fur_IT', 'ga_IE',
  38. 'gaa_GH', 'gez_ER', 'gez_ET',
  39. 'gl_ES', 'gsw_CH', 'gu_IN',
  40. 'gv_GB', 'ha_GH', 'ha_NE',
  41. 'ha_NG', 'ha_SD', 'haw_US',
  42. 'he_IL', 'hi_IN', 'hr_HR',
  43. 'hu_HU', 'hy_AM',
  44. 'id_ID', 'ig_NG',
  45. 'ii_CN', 'is_IS',
  46. 'it_CH', 'it_IT',
  47. 'ja_JP', 'ka_GE', 'kaj_NG',
  48. 'kam_KE', 'kcg_NG',
  49. 'kfo_CI', 'kk_KZ', 'kl_GL',
  50. 'km_KH', 'kn_IN',
  51. 'ko_KR', 'kok_IN', 'kpe_GN',
  52. 'kpe_LR', 'ku_IQ', 'ku_IR', 'ku_SY',
  53. 'ku_TR', 'kw_GB', 'ky_KG',
  54. 'ln_CD', 'ln_CG', 'lo_LA',
  55. 'lt_LT', 'lv_LV',
  56. 'mk_MK', 'ml_IN', 'mn_CN',
  57. 'mn_MN', 'mr_IN',
  58. 'ms_BN', 'ms_MY', 'mt_MT',
  59. 'my_MM', 'nb_NO', 'nds_DE',
  60. 'ne_IN', 'ne_NP', 'nl_BE',
  61. 'nl_NL', 'nn_NO',
  62. 'nr_ZA', 'nso_ZA', 'ny_MW',
  63. 'oc_FR', 'om_ET', 'om_KE',
  64. 'or_IN', 'pa_IN', 'pa_PK',
  65. 'pl_PL', 'ps_AF',
  66. 'pt_BR', 'pt_PT', 'ro_MD', 'ro_RO',
  67. 'ru_RU', 'ru_UA', 'rw_RW',
  68. 'sa_IN', 'se_FI', 'se_NO',
  69. 'sh_BA', 'sh_CS', 'sh_YU',
  70. 'si_LK', 'sid_ET', 'sk_SK',
  71. 'sl_SI', 'so_DJ', 'so_ET',
  72. 'so_KE', 'so_SO', 'sq_AL',
  73. 'sr_BA', 'sr_CS', 'sr_ME', 'sr_RS', 'sr_YU',
  74. 'ss_SZ', 'ss_ZA', 'st_LS',
  75. 'st_ZA', 'sv_FI', 'sv_SE',
  76. 'sw_KE', 'sw_TZ', 'syr_SY',
  77. 'ta_IN', 'te_IN', 'tg_TJ',
  78. 'th_TH', 'ti_ER', 'ti_ET',
  79. 'tig_ER', 'tn_ZA',
  80. 'to_TO', 'tr_TR',
  81. 'trv_TW', 'ts_ZA', 'tt_RU',
  82. 'ug_CN', 'uk_UA',
  83. 'ur_IN', 'ur_PK', 'uz_AF', 'uz_UZ',
  84. 've_ZA', 'vi_VN',
  85. 'wal_ET', 'wo_SN', 'xh_ZA',
  86. 'yo_NG', 'zh_CN', 'zh_HK',
  87. 'zh_MO', 'zh_SG', 'zh_TW', 'zu_ZA',
  88. );
  89. /**
  90. * Return a boolean, true or false
  91. *
  92. * @param integer $chanceOfGettingTrue Between 0 (always get false) and 100 (always get true).
  93. * @example true
  94. */
  95. public static function boolean($chanceOfGettingTrue = 50)
  96. {
  97. return mt_rand(1, 100) <= $chanceOfGettingTrue ? true: false;
  98. }
  99. /**
  100. * @example 'cfcd208495d565ef66e7dff9f98764da'
  101. */
  102. public static function md5()
  103. {
  104. return md5(mt_rand());
  105. }
  106. /**
  107. * @example 'b5d86317c2a144cd04d0d7c03b2b02666fafadf2'
  108. */
  109. public static function sha1()
  110. {
  111. return sha1(mt_rand());
  112. }
  113. /**
  114. * @example '85086017559ccc40638fcde2fecaf295e0de7ca51b7517b6aebeaaf75b4d4654'
  115. */
  116. public static function sha256()
  117. {
  118. return hash('sha256', mt_rand());
  119. }
  120. /**
  121. * @example 'fr_FR'
  122. */
  123. public function locale()
  124. {
  125. return static::randomElement(static::$localeData);
  126. }
  127. /**
  128. * @example 'FR'
  129. */
  130. public static function countryCode()
  131. {
  132. return static::randomElement(static::$countryCode);
  133. }
  134. /**
  135. * @example 'fr'
  136. */
  137. public static function languageCode()
  138. {
  139. return static::randomElement(static::$languageCode);
  140. }
  141. }