Address
class Address extends Base
Properties
protected Generator | $generator | from Base | |
protected UniqueGenerator | $unique | from Base | |
static protected | $citySuffix | ||
static protected | $streetSuffix | ||
static protected | $cityFormats | ||
static protected | $streetNameFormats | ||
static protected | $streetAddressFormats | ||
static protected | $addressFormats | ||
static protected | $buildingNumber | ||
static protected | $postcode | ||
static protected | $country |
Methods
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.
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 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.
No description
No description
No description
No description
No description
No description
No description
No description
No description
经纬度范围由于采取的数据是有限的,这里需要给予限制
No description
No description
Details
in
Base at line 45
mixed|null
optional(float|int $weight = 0.5, $default = null)
Chainable method for making any formatter optional.
in
Base at line 76
UniqueGenerator
unique(bool $reset = false, int $maxRetries = 10000)
Chainable method for making any formatter unique.
// will never return twice the same value
$faker->unique()->randomElement(array(1, 2, 3));
in
Base at line 108
ValidGenerator
valid(Closure $validator = null, int $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]
in
Base at line 118
static int
randomDigit()
Returns a random number between 0 and 9
in
Base at line 128
static int
randomDigitNotNull()
Returns a random number between 1 and 9
in
Base at line 139
static int
randomDigitNot(int $except)
Generates a random digit, which cannot be $except
in
Base at line 159
static int
randomNumber(int $nbDigits = null, bool $strict = false)
Returns a random integer with 0 to $nbDigits digits.
The maximum value returned is mt_getrandmax()
in
Base at line 188
static float
randomFloat(int $nbMaxDecimals = null, int|float $min = 0, int|float $max = null)
Return a random float number
in
Base at line 219
static int
numberBetween(int $int1 = 0, int $int2 = 2147483647)
Returns a random number between $int1 and $int2 (any order)
in
Base at line 233
static mixed
passthrough(mixed $value)
Returns the passed value
in
Base at line 243
static string
randomLetter()
Returns a random letter from a to z
in
Base at line 251
static
randomAscii()
Returns a random ASCII character (excluding accents and special chars)
in
Base at line 266
static array
randomElements(array $array = ['a', 'b', 'c'], int $count = 1, bool $allowDuplicates = false)
Returns randomly ordered subsequence of $count elements from a provided array
in
Base at line 312
static mixed
randomElement(array|Countable $array = ['a', 'b', 'c'])
Returns a random element from a passed array
in
Base at line 328
static int|string|null
randomKey(array $array = [])
Returns a random key from a passed associative array
in
Base at line 353
static array|string
shuffle(array|string $arg = '')
Returns a shuffled version of the argument.
This function accepts either an array, or a string.
in
Base at line 379
static array
shuffleArray(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.
in
Base at line 420
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.
in
Base at line 443
static string
numerify(string $string = '###')
Replaces all hash sign ('#') occurrences with a random number Replaces all percentage sign ('%') occurrences with a not null number
in
Base at line 477
static string
lexify(string $string = '????')
Replaces all question mark ('?') occurrences with a random letter
in
Base at line 489
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
in
Base at line 505
static string
asciify(string $string = '****')
Replaces * signs with random numbers and letters and special characters
in
Base at line 536
static string
regexify(string $regex = '')
Transforms a basic regular expression into a random string satisfying the expression.
in
Base at line 590
static string
toLower(string $string = '')
Converts string to lowercase.
Uses mb_string extension if available.
in
Base at line 602
static string
toUpper(string $string = '')
Converts string to uppercase.
Uses mb_string extension if available.
at line 36
city()
No description
at line 46
streetName()
No description
at line 56
streetAddress()
No description
at line 66
address()
No description
at line 76
static
citySuffix()
No description
at line 84
static
streetSuffix()
No description
at line 92
static
buildingNumber()
No description
at line 100
static
postcode()
No description
at line 108
static string
country()
No description
at line 120
static float
latitude(float|int $min = -85.05, float|int $max = 85.05)
经纬度范围由于采取的数据是有限的,这里需要给予限制
at line 131
static float
longitude(float|int $min = -180, float|int $max = 180)
No description
at line 140
static array
localCoordinates()
No description