src/Util/Mersenne_Twister.php
public function getNext($min = null, $max = null) {
    if (($min === null && $max !== null) || ($min !== null && $max === null))
      throw new Exception('Invalid arguments');

    if ($this->index === 0) {
      $this->generateTwister();
    }

    $y = $this->state[$this->index];
    $y = ($y ^ ($y >> 11)) & 0xffffffff;
    $y = ($y ^ (($y << 7) & 0x9d2c5680)) & 0xffffffff;
    $y = ($y ^ (($y << 15) & 0xefc60000)) & 0xffffffff;
    $y = ($y ^ ($y >> 18)) & 0xffffffff;

    $this->index = ($this->index + 1) % 624;

    if ($min === null && $max === null)
      return $y;

    $range = abs($max - $min);

    return min($min, $max) + ($y % ($range + 1));
  }
public function getNext($min = null, $max = null) {
    if (($min === null && $max !== null) || ($min !== null && $max === null))
      throw new Exception('Invalid arguments');

    if ($this->index === 0) {
      $this->generateTwister();
    }

    $y = $this->state[$this->index];
    $y = ($y ^ ($y >> 11)) & 0xffffffff;
    $y = ($y ^ (($y << 7) & 0x9d2c5680)) & 0xffffffff;
    $y = ($y ^ (($y << 15) & 0xefc60000)) & 0xffffffff;
    $y = ($y ^ ($y >> 18)) & 0xffffffff;

    $this->index = ($this->index + 1) % 624;

    if ($min === null && $max === null)
      return $y;

    $range = abs($max - $min);

    return min($min, $max) + ($y % ($range + 1));
  }
public function getNext ( $ min = null , $ max = null ) { if ( ( $ min === null && $ max !== null ) || ( $ min !== null && $ max === null ) ) throw new Exception ( 'Invalid arguments' ) ; if ( $ this -> index === 0 ) { $ this -> generateTwister ( ) ; } $ y = $ this -> state [ $ this -> index ] ; $ y = ( $ y ^ ( $ y >> 11 ) ) & 0xffffffff ; $ y = ( $ y ^ ( ( $ y << 7 ) & 0x9d2c5680 ) ) & 0xffffffff ; $ y = ( $ y ^ ( ( $ y << 15 ) & 0xefc60000 ) ) & 0xffffffff ; $ y = ( $ y ^ ( $ y >> 18 ) ) & 0xffffffff ; $ this -> index = ( $ this -> index + 1 ) % 624 ; if ( $ min === null && $ max === null ) return $ y ; $ range = abs ( $ max - $ min ) ; return min ( $ min , $ max ) + ( $ y % ( $ range + 1 ) ) ; }
Get the next pseudo-random number in the sequence

Returns the next pseudo-random number in the range specified.
The $max and $min are inclusive.
If $max and $min are omitted a large integer is returned.

@param $min The low end of the range (optional)
@param $max The high end of the range (optional)
Get the next pseudo - random number in the sequence