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

Commit 6917948

Browse files
committed
Better fallback, generate a value using en_US locale
1 parent be65136 commit 6917948

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Faker/Provider/Internet.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Faker\Provider;
44

5+
use Faker\Factory;
6+
57
class Internet extends \Faker\Provider\Base
68
{
79
protected static $freeEmailDomain = array('gmail.com', 'yahoo.com', 'hotmail.com');
@@ -98,7 +100,7 @@ public function userName()
98100

99101
// fallback in case transliterate() doesn't support the language and removed all letters
100102
if ($username === '') {
101-
return $this->generator->word;
103+
return $this->fakerEn()->userName;
102104
}
103105

104106
return $username;
@@ -133,7 +135,7 @@ public function domainWord()
133135

134136
// fallback in case transliterate() doesn't support the language and removed all letters
135137
if ($lastName === '') {
136-
return $this->generator->word;
138+
return $this->fakerEn()->domainWord;
137139
}
138140

139141
return $lastName;
@@ -352,4 +354,15 @@ protected static function toAscii($string)
352354

353355
return str_replace($arrayFrom, $arrayTo, $string);
354356
}
357+
358+
protected function fakerEn()
359+
{
360+
static $fakerEn;
361+
362+
if (!isset($fakerEn)) {
363+
$fakerEn = Factory::create('en_US');
364+
}
365+
366+
return $fakerEn;
367+
}
355368
}

0 commit comments

Comments
 (0)