Random data generator
@api
- Since
- 100.0.2
Definition at line 17 of file Random.php.
◆ getRandomNumber()
static getRandomNumber |
( |
|
$min = 0 , |
|
|
|
$max = null |
|
) |
| |
|
static |
Return a random number in the specified range
- Parameters
-
- Returns
- int A random integer value between min (or 0) and max
- Exceptions
-
Definition at line 62 of file Random.php.
65 $max = mt_getrandmax();
69 throw new LocalizedException(
new Phrase(
'Invalid range given.'));
72 return random_int($min, $max);
◆ getRandomString()
getRandomString |
( |
|
$length, |
|
|
|
$chars = null |
|
) |
| |
#- Get random string.
- Parameters
-
int | $length | |
null | string | $chars | |
- Returns
- string
- Exceptions
-
Definition at line 39 of file Random.php.
42 if (
null === $chars) {
43 $chars = self::CHARS_LOWERS.self::CHARS_UPPERS.self::CHARS_DIGITS;
46 $charsMaxKey = mb_strlen($chars) - 1;
47 for (
$i = 0;
$i < $length;
$i++) {
static getRandomNumber($min=0, $max=null)
◆ getUniqueHash()
getUniqueHash |
( |
|
$prefix = '' | ) |
|
Generate a hash from unique ID.
- Parameters
-
- Returns
- string
- Exceptions
-
Definition at line 82 of file Random.php.
getRandomString($length, $chars=null)
◆ CHARS_DIGITS
const CHARS_DIGITS = '0123456789' |
◆ CHARS_LOWERS
const CHARS_LOWERS = 'abcdefghijklmnopqrstuvwxyz' |
#+ Frequently used character classes
Definition at line 22 of file Random.php.
◆ CHARS_UPPERS
const CHARS_UPPERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
The documentation for this class was generated from the following file: