mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-22 08:19:52 +01:00
commit
b19c269141
@ -13,7 +13,7 @@ class Name
|
||||
|
||||
public function guessFormat($name)
|
||||
{
|
||||
$name = strtolower($name);
|
||||
$name = static::toLower($name);
|
||||
$generator = $this->generator;
|
||||
if (preg_match('/^is[_A-Z]/', $name)) {
|
||||
return function() use ($generator) { return $generator->boolean; };
|
||||
|
@ -77,7 +77,7 @@ class EntityPopulator
|
||||
protected function isColumnBehavior($columnMap)
|
||||
{
|
||||
foreach ($columnMap->getTable()->getBehaviors() as $name => $params) {
|
||||
$columnName = strtolower($columnMap->getName());
|
||||
$columnName = static::toLower($columnMap->getName());
|
||||
switch ($name) {
|
||||
case 'nested_set':
|
||||
$columnNames = array($params['left_column'], $params['right_column'], $params['level_column']);
|
||||
|
@ -79,7 +79,7 @@ class Address extends \Faker\Provider\Base
|
||||
*/
|
||||
public static function postcode()
|
||||
{
|
||||
return strtoupper(static::bothify(static::randomElement(static::$postcode)));
|
||||
return static::toUpper(static::bothify(static::randomElement(static::$postcode)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +74,7 @@ class Lorem extends \Faker\Provider\Base
|
||||
*
|
||||
* @example 'Lorem ipsum dolor sit amet.'
|
||||
* @param integer $nbWords around how many words the sentence should contain
|
||||
* @param boolean $variableNbWords set to false if you want exactly $nbWords returned,
|
||||
* @param boolean $variableNbWords set to false if you want exactly $nbWords returned,
|
||||
* otherwise $nbWords may vary by +/-40% with a minimum of 1
|
||||
* @return string
|
||||
*/
|
||||
@ -115,7 +115,7 @@ class Lorem extends \Faker\Provider\Base
|
||||
*
|
||||
* @example 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.'
|
||||
* @param integer $nbSentences around how many sentences the paragraph should contain
|
||||
* @param boolean $variableNbSentences set to false if you want exactly $nbSentences returned,
|
||||
* @param boolean $variableNbSentences set to false if you want exactly $nbSentences returned,
|
||||
* otherwise $nbSentences may vary by +/-40% with a minimum of 1
|
||||
* @return string
|
||||
*/
|
||||
@ -173,7 +173,7 @@ class Lorem extends \Faker\Provider\Base
|
||||
}
|
||||
array_pop($text);
|
||||
}
|
||||
$text[0][0] = strtoupper($text[0][0]);
|
||||
$text[0][0] = static::toUpper($text[0][0]);
|
||||
$text[count($text) - 1] .= '.';
|
||||
} else if ($maxNbChars < 100) {
|
||||
// join sentences
|
||||
|
@ -235,9 +235,14 @@ class Address extends \Faker\Provider\Address
|
||||
return static::randomElement(static::$streetSuffixWord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly return a building number.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function buildingNumber()
|
||||
{
|
||||
return strtoupper(static::bothify(static::randomElement(static::$buildingNumber)));
|
||||
return static::toUpper(static::bothify(static::randomElement(static::$buildingNumber)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ class Internet extends \Faker\Provider\Internet
|
||||
public function userName()
|
||||
{
|
||||
$format = static::randomElement(static::$userNameFormats);
|
||||
return strtolower(static::toAscii(static::bothify($this->generator->parse($format))));
|
||||
return static::toLower(static::toAscii(static::bothify($this->generator->parse($format))));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,6 +62,6 @@ class Internet extends \Faker\Provider\Internet
|
||||
$company = $companyElements[0];
|
||||
$company = preg_replace('/\W/', '', $company);
|
||||
|
||||
return strtolower(static::toAscii($company));
|
||||
return static::toLower(static::toAscii($company));
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class Internet extends \Faker\Provider\Internet
|
||||
public function userName()
|
||||
{
|
||||
$format = static::randomElement(static::$userNameFormats);
|
||||
return strtolower(static::toAscii(static::bothify($this->generator->parse($format))));
|
||||
return static::toLower(static::toAscii(static::bothify($this->generator->parse($format))));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,6 +40,6 @@ class Internet extends \Faker\Provider\Internet
|
||||
$company = $companyElements[0];
|
||||
$company = preg_replace('/\W/', '', $company);
|
||||
|
||||
return strtolower(static::toAscii($company));
|
||||
return static::toLower(static::toAscii($company));
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class Internet extends \Faker\Provider\Internet
|
||||
public function userName()
|
||||
{
|
||||
$format = static::randomElement(static::$userNameFormats);
|
||||
return strtolower(static::toAscii(static::bothify($this->generator->parse($format))));
|
||||
return static::toLower(static::toAscii(static::bothify($this->generator->parse($format))));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,6 +40,6 @@ class Internet extends \Faker\Provider\Internet
|
||||
$company = $companyElements[0];
|
||||
$company = preg_replace('/\W/', '', $company);
|
||||
|
||||
return strtolower(static::toAscii($company));
|
||||
return static::toLower(static::toAscii($company));
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class Address extends \Faker\Provider\Base
|
||||
|
||||
public static function postcode()
|
||||
{
|
||||
return strtoupper(static::bothify(static::randomElement(static::$postcode)));
|
||||
return static::toUpper(static::bothify(static::randomElement(static::$postcode)));
|
||||
}
|
||||
|
||||
public static function regionSuffix()
|
||||
|
Loading…
x
Reference in New Issue
Block a user