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

Commit

Permalink
Merge pull request #1112 from dunglas/improve_transliterate_perf
Browse files Browse the repository at this point in the history
Improve Internet::transliterate performance
  • Loading branch information
fzaninotto authored Dec 2, 2016
2 parents 7ef2719 + b77b90a commit 71c5cce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Faker/Provider/Internet.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ public static function macAddress()

protected static function transliterate($string)
{
if (0 === preg_match('/[^A-Za-z0-9_.]/', $string)) {
return $string;
}

$transId = 'Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC;';
if (function_exists('transliterator_transliterate') && $transliterator = \Transliterator::create($transId)) {
$transString = $transliterator->transliterate($string);
Expand Down

0 comments on commit 71c5cce

Please sign in to comment.