public function getRandomInteger($min = 0, $max = PHP_INT_MAX)
    {
        $min = (int) $min;
        $max = (int) $max;
        $range = $max - $min;

        $bits  = $this->getBitsInInteger($range);
        $bytes = $this->getBytesInBits($bits);
        $mask  = (int) ((1 << $bits) - 1);

        do {
            $byteString = $this->generator->generate($bytes);
            $result = hexdec(bin2hex($byteString)) & $mask;
        } while ($result > $range);

        return (int) $result + $min;
    }
public function getRandomInteger($min = 0, $max = PHP_INT_MAX)
    {
        $min = (int) $min;
        $max = (int) $max;
        $range = $max - $min;

        $bits  = $this->getBitsInInteger($range);
        $bytes = $this->getBytesInBits($bits);
        $mask  = (int) ((1 << $bits) - 1);

        do {
            $byteString = $this->generator->generate($bytes);
            $result = hexdec(bin2hex($byteString)) & $mask;
        } while ($result > $range);

        return (int) $result + $min;
    }
public function getRandomInteger ( $ min = 0 , $ max = PHP_INT_MAX ) { $ min = ( int ) $ min ; $ max = ( int ) $ max ; $ range = $ max - $ min ; $ bits = $ this -> getBitsInInteger ( $ range ) ; $ bytes = $ this -> getBytesInBits ( $ bits ) ; $ mask = ( int ) ( ( 1 << $ bits ) - 1 ) ; do { $ byteString = $ this -> generator -> generate ( $ bytes ) ; $ result = hexdec ( bin2hex ( $ byteString ) ) & $ mask ; } while ( $ result > $ range ) ; return ( int ) $ result + $ min ; }
Get a random integer within the specified range.

@param  integer $min The minimum expected value. Defaults to 0.
@param  integer $max The maximum expected value. Defaults to PHP_INT_MAX.
@return integer A random integer between the specified values, inclusive.
Get a random integer within the specified range .