1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-22 08:19:52 +01:00

fixed problem with Utf-8 string

When string is utf-8 coded, strtolower breaks strings. mb_string should be used when available
This commit is contained in:
jasir 2012-10-12 00:40:13 +02:00 committed by Antoine Corcy
parent 7c234f6dcc
commit 0a89d8e662
2 changed files with 23 additions and 3 deletions

View File

@ -126,4 +126,24 @@ class Base
{
return static::lexify(static::numerify($string));
}
}
/**
* Converts string to lowercase.
* Uses mb_string extension if available
* @param string $string String that should be converted to lowercase
* @return string
*/
public static function toLower($string) {
return extension_loaded('mbstring') ? mb_strtolower($string) : strtolower($string);
}
/**
* Converts string to uppercase.
* Uses mb_string extension if available
* @param string $string String that should be converted to uppercase
* @return string
*/
public static function toUpper($string) {
return extension_loaded('mbstring') ? mb_strtoupper($string) : strtoupper($string);
}
}

View File

@ -70,7 +70,7 @@ class Internet extends \Faker\Provider\Base
public function userName()
{
$format = static::randomElement(static::$userNameFormats);
return strtolower(static::bothify($this->generator->parse($format)));
return static::toLower(static::bothify($this->generator->parse($format)));
}
/**
@ -91,7 +91,7 @@ class Internet extends \Faker\Provider\Base
$company = $companyElements[0];
$company = preg_replace('/\W/', '', $company);
return strtolower($company);
return static::toLower($company);
}
/**