Address
class Address extends Address
Methods
Returns a random integer with 0 to $nbDigits digits.
Return a random float number
Returns a random number between $int1 and $int2 (any order)
Returns a random ASCII character (excluding accents and special chars)
Returns randomly ordered subsequence of $count elements from a provided array
Returns a random element from a passed array
Returns a random key from a passed associative array
Returns a shuffled version of the argument.
Returns a shuffled version of the array.
Returns a shuffled version of the string.
Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a not null number
Replaces all question mark ('?') occurrences with a random letter
Replaces hash signs ('#') and question marks ('?') with random numbers and letters An asterisk ('*') is replaced with either a random number or a random letter
Replaces * signs with random numbers and letters and special characters
Transforms a basic regular expression into a random string satisfying the expression.
Chainable method for making any formatter optional.
Chainable method for making any formatter unique.
Chainable method for forcing any formatter to return only valid values.
No description
No description
No description
No description
No description
Details
static
integer
randomNumber(
integer $nbDigits = null,
boolean $strict = false)
Returns a random integer with 0 to $nbDigits digits.
The maximum value returned is mt_getrandmax()
static
float
randomFloat(
int $nbMaxDecimals = null,
int|float $min,
int|float $max = null)
Return a random float number
static
integer
numberBetween(
integer $int1,
integer $int2 = 2147483647)
Returns a random number between $int1 and $int2 (any order)
static
array
randomElements(
array $array = array('a', 'b', 'c'),
integer $count = 1,
boolean $allowDuplicates = false)
Returns randomly ordered subsequence of $count elements from a provided array
static
mixed
randomElement(
array $array = array('a', 'b', 'c'))
Returns a random element from a passed array
static
int|string|null
randomKey(
array $array = array())
Returns a random key from a passed associative array
static
array|string
shuffle(
array|string $arg = '')
Returns a shuffled version of the argument.
This function accepts either an array, or a string.
static
array
shuffleArray(
array $array = array())
Returns a shuffled version of the array.
This function does not mutate the original array. It uses the Fisher–Yates algorithm, which is unbiased, together with a Mersenne twister random generator. This function is therefore more random than PHP's shuffle() function, and it is seedable.
static
string
shuffleString(
string $string = '',
string $encoding = 'UTF-8')
Returns a shuffled version of the string.
This function does not mutate the original string. It uses the Fisher–Yates algorithm, which is unbiased, together with a Mersenne twister random generator. This function is therefore more random than PHP's shuffle() function, and it is seedable. Additionally, it is UTF8 safe if the mb extension is available.
static
string
numerify(
string $string = '###')
Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a not null number
static
string
lexify(
string $string = '????')
Replaces all question mark ('?') occurrences with a random letter
static
string
bothify(
string $string = '## ??')
Replaces hash signs ('#') and question marks ('?') with random numbers and letters An asterisk ('*') is replaced with either a random number or a random letter
static
string
asciify(
string $string = '****')
Replaces * signs with random numbers and letters and special characters
static
string
regexify(
string $regex = '')
Transforms a basic regular expression into a random string satisfying the expression.
static
string
toLower(
string $string = '')
Converts string to lowercase.
Uses mb_string extension if available.
static
string
toUpper(
string $string = '')
Converts string to uppercase.
Uses mb_string extension if available.
mixed|null
optional($weight = 0.5, $default = null)
Chainable method for making any formatter optional.
UniqueGenerator
unique(
boolean $reset = false,
integer $maxRetries = 10000)
Chainable method for making any formatter unique.
// will never return twice the same value
$faker->unique()->randomElement(array(1, 2, 3));
ValidGenerator
valid(
Closure $validator = null,
integer $maxRetries = 10000)
Chainable method for forcing any formatter to return only valid values.
The value validity is determined by a function passed as first argument.
$values = array();
$evenValidator = function ($digit) {
return $digit % 2 === 0;
};
for ($i=0; $i < 10; $i++) {
$values []= $faker->valid($evenValidator)->randomDigit;
}
print_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6]