Pseudorandom number generator (PRNG)
More...
|
static | getBytes ($length) |
| Generate random bytes using different approaches If PHP 7 is running we use the random_bytes() function.
|
|
static | getBoolean () |
| Generate random boolean.
|
|
static | getInteger ($min, $max) |
| Generate a random integer between $min and $max.
|
|
static | getFloat () |
| Generate random float (0..1) This function generates floats with platform-dependent precision.
|
|
static | getString ($length, $charlist=null) |
| Generate a random string of specified length.
|
|
Pseudorandom number generator (PRNG)
Generate random boolean.
- Returns
- bool
static getBytes |
( |
|
$length | ) |
|
|
static |
Generate random bytes using different approaches If PHP 7 is running we use the random_bytes() function.
- Parameters
-
- Returns
- string
- Exceptions
-
Exception\RuntimeException | |
Generate random float (0..1) This function generates floats with platform-dependent precision.
PHP uses double precision floating-point format (64-bit) which has 52-bits of significand precision. We gather 7 bytes of random data, and we fix the exponent to the bias (1023). In this way we generate a float of 1.mantissa.
- Returns
- float
static getInteger |
( |
|
$min, |
|
|
|
$max |
|
) |
| |
|
static |
Generate a random integer between $min and $max.
- Parameters
-
- Returns
- int
- Exceptions
-
Exception\DomainException | |
static getString |
( |
|
$length, |
|
|
|
$charlist = null |
|
) |
| |
|
static |
Generate a random string of specified length.
Uses supplied character list for generating the new string. If no character list provided - uses Base 64 character set.
- Parameters
-
int | $length | |
string | null | $charlist | |
- Returns
- string
- Exceptions
-
Exception\DomainException | |