1 | <?php |
||
12 | class Random |
||
13 | { |
||
14 | const MT = '\Savvot\Random\MtRand'; |
||
15 | const XORSHIFT = '\Savvot\Random\XorShiftRand'; |
||
16 | const HASH = '\Savvot\Random\HashRand'; |
||
17 | |||
18 | /** |
||
19 | * Creates RNG from specified class and initializes it with given seed |
||
20 | * |
||
21 | * @param string $seed Seed to initialize generator's state. Defaults to null (auto) |
||
22 | * @param string $rngClass Generator's class. Must be the child of AbstractRand. Defaults to XorShiftRand |
||
23 | * @return AbstractRand Newly created PRNG |
||
24 | * @throws RandException if generator class is invalid |
||
25 | */ |
||
26 | public static function create($seed = null, $rngClass = self::XORSHIFT) |
||
34 | |||
35 | /** |
||
36 | * Creates RNG from previously saved state |
||
37 | * |
||
38 | * @param array $state State array created with getState() method |
||
39 | * @return AbstractRand Newly created PRNG |
||
40 | * @throws RandException if specified state is invalid |
||
41 | */ |
||
42 | public static function createFromState(array $state) |
||
59 | } |
||
60 |