SystemRandomness
The real source of entropy: SystemRandomness::bytes()/SystemRandomness::int() answer from PHP’s CSPRNG exactly like random_bytes()/random_int() always did.
This is what the container binds RandomnessInterface to by default; nothing here is mockable, which is the point — tests reach for SeededRandomness instead of stubbing this class.
Synopsis
Section titled “Synopsis”final class SystemRandomness implements RandomnessInterface
| Implements | RandomnessInterface |
| Source | Support/Random/SystemRandomness.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
bytes(positive-int $length): string | $length cryptographically-random-shaped bytes. |
int(int $min, int $max): int | A random integer in the inclusive range [$min, $max]. |
bytes()
Section titled “bytes()”public function bytes(positive-int $length): string
$length cryptographically-random-shaped bytes.
| Parameter | Type | Description |
|---|---|---|
$length | positive-int |
Returns string
public function int(int $min, int $max): int
A random integer in the inclusive range [$min, $max].
Replaces a direct random_int($min, $max) call.
| Parameter | Type | Description |
|---|---|---|
$min | int | |
$max | int |
Returns int