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

Commit

Permalink
Work on cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
vlakoff committed Oct 25, 2016
1 parent fb45001 commit 5bc0bbb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Faker/Provider/Internet.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ public function userName()
$username = static::bothify($this->generator->parse($format));

$username = strtolower(static::transliterate($username));
$username = rtrim($username, '.');

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

// clean possible trailing dots from first/last names
$username = str_replace('..', '.', $username);
$username = rtrim($username, '.');

return $username;
}
/**
Expand Down Expand Up @@ -129,13 +132,15 @@ public function domainWord()
$lastName = $this->generator->format('lastName');

$lastName = strtolower(static::transliterate($lastName));
$lastName = rtrim($lastName, '.');

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

// clean possible trailing dot from last name
$lastName = rtrim($lastName, '.');

return $lastName;
}

Expand Down

0 comments on commit 5bc0bbb

Please sign in to comment.