PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Faker/Provider/Internet.php

http://github.com/fzaninotto/Faker
PHP | 362 lines | 265 code | 40 blank | 57 comment | 13 complexity | 33760cb4759927d417ac7d174169d6bb MD5 | raw file
  1. <?php
  2. namespace Faker\Provider;
  3. class Internet extends Base
  4. {
  5. protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com');
  6. protected static $tld = array('com', 'com', 'com', 'com', 'com', 'com', 'biz', 'info', 'net', 'org');
  7. protected static $userNameFormats = array(
  8. '{{lastName}}.{{firstName}}',
  9. '{{firstName}}.{{lastName}}',
  10. '{{firstName}}##',
  11. '?{{lastName}}',
  12. );
  13. protected static $emailFormats = array(
  14. '{{userName}}@{{domainName}}',
  15. '{{userName}}@{{freeEmailDomain}}',
  16. );
  17. protected static $urlFormats = array(
  18. 'http://www.{{domainName}}/',
  19. 'http://{{domainName}}/',
  20. 'http://www.{{domainName}}/{{slug}}',
  21. 'http://www.{{domainName}}/{{slug}}',
  22. 'https://www.{{domainName}}/{{slug}}',
  23. 'http://www.{{domainName}}/{{slug}}.html',
  24. 'http://{{domainName}}/{{slug}}',
  25. 'http://{{domainName}}/{{slug}}',
  26. 'http://{{domainName}}/{{slug}}.html',
  27. 'https://{{domainName}}/{{slug}}.html',
  28. );
  29. /**
  30. * @example 'jdoe@acme.biz'
  31. */
  32. public function email()
  33. {
  34. $format = static::randomElement(static::$emailFormats);
  35. return $this->generator->parse($format);
  36. }
  37. /**
  38. * @example 'jdoe@example.com'
  39. */
  40. final public function safeEmail()
  41. {
  42. return preg_replace('/\s/u', '', $this->userName() . '@' . static::safeEmailDomain());
  43. }
  44. /**
  45. * @example 'jdoe@gmail.com'
  46. */
  47. public function freeEmail()
  48. {
  49. return preg_replace('/\s/u', '', $this->userName() . '@' . static::freeEmailDomain());
  50. }
  51. /**
  52. * @example 'jdoe@dawson.com'
  53. */
  54. public function companyEmail()
  55. {
  56. return preg_replace('/\s/u', '', $this->userName() . '@' . $this->domainName());
  57. }
  58. /**
  59. * @example 'gmail.com'
  60. */
  61. public static function freeEmailDomain()
  62. {
  63. return static::randomElement(static::$freeEmailDomain);
  64. }
  65. /**
  66. * @example 'example.org'
  67. */
  68. final public static function safeEmailDomain()
  69. {
  70. $domains = array(
  71. 'example.com',
  72. 'example.org',
  73. 'example.net'
  74. );
  75. return static::randomElement($domains);
  76. }
  77. /**
  78. * @example 'jdoe'
  79. */
  80. public function userName()
  81. {
  82. $format = static::randomElement(static::$userNameFormats);
  83. $username = static::bothify($this->generator->parse($format));
  84. $username = strtolower(static::transliterate($username));
  85. // check if transliterate() didn't support the language and removed all letters
  86. if (trim($username, '._') === '') {
  87. throw new \Exception('userName failed with the selected locale. Try a different locale or activate the "intl" PHP extension.');
  88. }
  89. // clean possible trailing dots from first/last names
  90. $username = str_replace('..', '.', $username);
  91. $username = rtrim($username, '.');
  92. return $username;
  93. }
  94. /**
  95. * @example 'fY4èHdZv68'
  96. */
  97. public function password($minLength = 6, $maxLength = 20)
  98. {
  99. $pattern = str_repeat('*', $this->numberBetween($minLength, $maxLength));
  100. return $this->asciify($pattern);
  101. }
  102. /**
  103. * @example 'tiramisu.com'
  104. */
  105. public function domainName()
  106. {
  107. return $this->domainWord() . '.' . $this->tld();
  108. }
  109. /**
  110. * @example 'faber'
  111. */
  112. public function domainWord()
  113. {
  114. $lastName = $this->generator->format('lastName');
  115. $lastName = strtolower(static::transliterate($lastName));
  116. // check if transliterate() didn't support the language and removed all letters
  117. if (trim($lastName, '._') === '') {
  118. throw new \Exception('domainWord failed with the selected locale. Try a different locale or activate the "intl" PHP extension.');
  119. }
  120. // clean possible trailing dot from last name
  121. $lastName = rtrim($lastName, '.');
  122. return $lastName;
  123. }
  124. /**
  125. * @example 'com'
  126. */
  127. public function tld()
  128. {
  129. return static::randomElement(static::$tld);
  130. }
  131. /**
  132. * @example 'http://www.runolfsdottir.com/'
  133. */
  134. public function url()
  135. {
  136. $format = static::randomElement(static::$urlFormats);
  137. return $this->generator->parse($format);
  138. }
  139. /**
  140. * @example 'aut-repellat-commodi-vel-itaque-nihil-id-saepe-nostrum'
  141. */
  142. public function slug($nbWords = 6, $variableNbWords = true)
  143. {
  144. if ($nbWords <= 0) {
  145. return '';
  146. }
  147. if ($variableNbWords) {
  148. $nbWords = (int) ($nbWords * mt_rand(60, 140) / 100) + 1;
  149. }
  150. $words = $this->generator->words($nbWords);
  151. return join('-', $words);
  152. }
  153. /**
  154. * @example '237.149.115.38'
  155. */
  156. public function ipv4()
  157. {
  158. return long2ip(mt_rand(0, 1) == 0 ? mt_rand(-2147483648, -2) : mt_rand(16777216, 2147483647));
  159. }
  160. /**
  161. * @example '35cd:186d:3e23:2986:ef9f:5b41:42a4:e6f1'
  162. */
  163. public function ipv6()
  164. {
  165. $res = array();
  166. for ($i=0; $i < 8; $i++) {
  167. $res []= dechex(mt_rand(0, "65535"));
  168. }
  169. return join(':', $res);
  170. }
  171. /**
  172. * @example '10.1.1.17'
  173. */
  174. public static function localIpv4()
  175. {
  176. if (static::numberBetween(0, 1) === 0) {
  177. // 10.x.x.x range
  178. return long2ip(static::numberBetween(ip2long("10.0.0.0"), ip2long("10.255.255.255")));
  179. }
  180. // 192.168.x.x range
  181. return long2ip(static::numberBetween(ip2long("192.168.0.0"), ip2long("192.168.255.255")));
  182. }
  183. /**
  184. * @example '32:F1:39:2F:D6:18'
  185. */
  186. public static function macAddress()
  187. {
  188. for ($i=0; $i<6; $i++) {
  189. $mac[] = sprintf('%02X', static::numberBetween(0, 0xff));
  190. }
  191. $mac = implode(':', $mac);
  192. return $mac;
  193. }
  194. protected static function transliterate($string)
  195. {
  196. if (0 === preg_match('/[^A-Za-z0-9_.]/', $string)) {
  197. return $string;
  198. }
  199. $transId = 'Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC;';
  200. if (class_exists('Transliterator', false) && $transliterator = \Transliterator::create($transId)) {
  201. $transString = $transliterator->transliterate($string);
  202. } else {
  203. $transString = static::toAscii($string);
  204. }
  205. return preg_replace('/[^A-Za-z0-9_.]/u', '', $transString);
  206. }
  207. protected static function toAscii($string)
  208. {
  209. static $arrayFrom, $arrayTo;
  210. if (empty($arrayFrom)) {
  211. $transliterationTable = array(
  212. 'IJ'=>'I', 'Ö'=>'O', 'Œ'=>'O', 'Ü'=>'U', 'ä'=>'a', 'æ'=>'a',
  213. 'ij'=>'i', 'ö'=>'o', 'œ'=>'o', 'ü'=>'u', 'ß'=>'s', 'ſ'=>'s',
  214. 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A',
  215. 'Æ'=>'A', 'Ā'=>'A', 'Ą'=>'A', 'Ă'=>'A', 'Ç'=>'C', 'Ć'=>'C',
  216. 'Č'=>'C', 'Ĉ'=>'C', 'Ċ'=>'C', 'Ď'=>'D', 'Đ'=>'D', 'È'=>'E',
  217. 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ē'=>'E', 'Ę'=>'E', 'Ě'=>'E',
  218. 'Ĕ'=>'E', 'Ė'=>'E', 'Ĝ'=>'G', 'Ğ'=>'G', 'Ġ'=>'G', 'Ģ'=>'G',
  219. 'Ĥ'=>'H', 'Ħ'=>'H', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I',
  220. 'Ī'=>'I', 'Ĩ'=>'I', 'Ĭ'=>'I', 'Į'=>'I', 'İ'=>'I', 'Ĵ'=>'J',
  221. 'Ķ'=>'K', 'Ľ'=>'K', 'Ĺ'=>'K', 'Ļ'=>'K', 'Ŀ'=>'K', 'Ł'=>'L',
  222. 'Ñ'=>'N', 'Ń'=>'N', 'Ň'=>'N', 'Ņ'=>'N', 'Ŋ'=>'N', 'Ò'=>'O',
  223. 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ø'=>'O', 'Ō'=>'O', 'Ő'=>'O',
  224. 'Ŏ'=>'O', 'Ŕ'=>'R', 'Ř'=>'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ё'=>'E', 'ж'=>'Z', 'з'=>'Z', 'и'=>'I', 'й'=>'I', 'к'=>'K',
  295. 'л'=>'L', 'м'=>'M', 'н'=>'N', 'о'=>'O', 'п'=>'P', 'р'=>'R',
  296. 'с'=>'S', 'т'=>'T', 'у'=>'U', 'ф'=>'F', 'х'=>'K', 'ц'=>'T',
  297. 'ч'=>'C', 'ш'=>'S', 'щ'=>'S', 'ы'=>'Y', 'э'=>'E', 'ю'=>'Y',
  298. 'я'=>'Y', 'ð'=>'d', 'Ð'=>'D', 'þ'=>'t', 'Þ'=>'T', 'ა'=>'a',
  299. 'ბ'=>'b', 'გ'=>'g', 'დ'=>'d', 'ე'=>'e', 'ვ'=>'v', 'ზ'=>'z',
  300. 'თ'=>'t', 'ი'=>'i', 'კ'=>'k', 'ლ'=>'l', 'მ'=>'m', 'ნ'=>'n',
  301. 'ო'=>'o', 'პ'=>'p', 'ჟ'=>'z', 'რ'=>'r', 'ს'=>'s', 'ტ'=>'t',
  302. 'უ'=>'u', 'ფ'=>'p', 'ქ'=>'k', 'ღ'=>'g', 'ყ'=>'q', 'შ'=>'s',
  303. 'ჩ'=>'c', 'ც'=>'t', 'ძ'=>'d', 'წ'=>'t', 'ჭ'=>'c', 'ხ'=>'k',
  304. 'ჯ'=>'j', 'ჰ'=>'h', 'ţ'=>'t', 'ʼ'=>"'", '̧'=>'', 'ḩ'=>'h',
  305. '‘'=>"'", '’'=>"'", 'ừ'=>'u', '/'=>'', 'ế'=>'e', 'ả'=>'a',
  306. 'ị'=>'i', 'ậ'=>'a', 'ệ'=>'e', 'ỉ'=>'i', 'ồ'=>'o', 'ề'=>'e',
  307. 'ơ'=>'o', 'ạ'=>'a', 'ẵ'=>'a', 'ư'=>'u', 'ằ'=>'a', 'ầ'=>'a',
  308. 'ḑ'=>'d', 'Ḩ'=>'H', 'Ḑ'=>'D', 'ș'=>'s', 'ț'=>'t', 'ộ'=>'o',
  309. 'ắ'=>'a', 'ş'=>'s', "'"=>'', 'ու'=>'u', 'ա'=>'a', 'բ'=>'b',
  310. 'գ'=>'g', 'դ'=>'d', 'ե'=>'e', 'զ'=>'z', 'է'=>'e', 'ը'=>'y',
  311. 'թ'=>'t', 'ժ'=>'zh', 'ի'=>'i', 'լ'=>'l', 'խ'=>'kh', 'ծ'=>'ts',
  312. 'կ'=>'k', 'հ'=>'h', 'ձ'=>'dz', 'ղ'=>'gh', 'ճ'=>'ch', 'մ'=>'m',
  313. 'յ'=>'y', 'ն'=>'n', 'շ'=>'sh', 'ո'=>'o', 'չ'=>'ch', 'պ'=>'p',
  314. 'ջ'=>'j', 'ռ'=>'r', 'ս'=>'s', 'վ'=>'v', 'տ'=>'t', 'ր'=>'r',
  315. 'ց'=>'ts', 'փ'=>'p', 'ք'=>'q', 'և'=>'ev', 'օ'=>'o', 'ֆ'=>'f',
  316. );
  317. $arrayFrom = array_keys($transliterationTable);
  318. $arrayTo = array_values($transliterationTable);
  319. }
  320. return str_replace($arrayFrom, $arrayTo, $string);
  321. }
  322. }