MersenneTwister
in package
Custom random algorithm to get consistent behaviour between PHP versions.
Copied from: http://www.dr-chuck.com/csev-blog/2015/09/a-mersenne_twister-implementation-in-php/
Table of Contents
Properties
- $index : mixed
- $instance : MersenneTwister
- Singleton variable
- $state : mixed
Methods
- __construct() : mixed
- getInstance() : MersenneTwister
- getNext() : mixed
- init() : void
- setSeed() : mixed
- shuffle() : array<string|int, mixed>
- Shuffle with seed
- generateTwister() : mixed
Properties
$index
private
mixed
$index
= 0
$instance
Singleton variable
private
static MersenneTwister
$instance
= null
$state
private
mixed
$state
= array()
Methods
__construct()
public
__construct([int $seed = null ]) : mixed
Parameters
- $seed : int = null
getInstance()
public
static getInstance() : MersenneTwister
Return values
MersenneTwistergetNext()
public
getNext([int $min = null ][, int $max = null ]) : mixed
Parameters
- $min : int = null
- $max : int = null
init()
public
static init(int $seed) : void
Parameters
- $seed : int
setSeed()
public
setSeed(int $seed) : mixed
Parameters
- $seed : int
shuffle()
Shuffle with seed
public
shuffle(array<string|int, mixed> $arr) : array<string|int, mixed>
Parameters
- $arr : array<string|int, mixed>
Return values
array<string|int, mixed>generateTwister()
private
generateTwister() : mixed