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

Commit 5bc0bbb

Browse files
committed
Work on cleaning
1 parent fb45001 commit 5bc0bbb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Faker/Provider/Internet.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ public function userName()
9494
$username = static::bothify($this->generator->parse($format));
9595

9696
$username = strtolower(static::transliterate($username));
97-
$username = rtrim($username, '.');
9897

9998
// check if transliterate() didn't support the language and removed all letters
10099
if (preg_match('/^[._]*$/', $username)) {
101100
throw new \Exception('userName failed with the selected locale. Try a different locale or activate the "intl" PHP extension.');
102101
}
103102

103+
// clean possible trailing dots from first/last names
104+
$username = str_replace('..', '.', $username);
105+
$username = rtrim($username, '.');
106+
104107
return $username;
105108
}
106109
/**
@@ -129,13 +132,15 @@ public function domainWord()
129132
$lastName = $this->generator->format('lastName');
130133

131134
$lastName = strtolower(static::transliterate($lastName));
132-
$lastName = rtrim($lastName, '.');
133135

134136
// check if transliterate() didn't support the language and removed all letters
135137
if (preg_match('/^[._]*$/', $lastName)) {
136138
throw new \Exception('domainWord failed with the selected locale. Try a different locale or activate the "intl" PHP extension.');
137139
}
138140

141+
// clean possible trailing dot from last name
142+
$lastName = rtrim($lastName, '.');
143+
139144
return $lastName;
140145
}
141146

0 commit comments

Comments
 (0)