src/Int.php
public static function random($min = 0, $max = 1, $seed = null)
    {
        if (!static::is($min) || !static::is($max)) {
            throw new \InvalidArgumentException("The \$min and \$max parameters must be of type int.");
        }

        if ($min > $max) {
            trigger_error("The \$min value cannot be greater than the \$max value.", E_USER_WARNING);

            return false;
        }

        if (!is_null($seed) && static::is($seed)) {
            mt_srand($seed);
        }

        $rand = mt_rand($min, $max);

        // unseed (random reseed) random generator
        mt_srand();

        return $rand;
    }
public static function random($min = 0, $max = 1, $seed = null)
    {
        if (!static::is($min) || !static::is($max)) {
            throw new \InvalidArgumentException("The \$min and \$max parameters must be of type int.");
        }

        if ($min > $max) {
            trigger_error("The \$min value cannot be greater than the \$max value.", E_USER_WARNING);

            return false;
        }

        if (!is_null($seed) && static::is($seed)) {
            mt_srand($seed);
        }

        $rand = mt_rand($min, $max);

        // unseed (random reseed) random generator
        mt_srand();

        return $rand;
    }
public static function random ( $ min = 0 , $ max = 1 , $ seed = null ) { if ( ! static :: is ( $ min ) || ! static :: is ( $ max ) ) { throw new \ InvalidArgumentException ( "The \$min and \$max parameters must be of type int." ) ; } if ( $ min > $ max ) { trigger_error ( "The \$min value cannot be greater than the \$max value." , E_USER_WARNING ) ; return false ; } if ( ! is_null ( $ seed ) && static :: is ( $ seed ) ) { mt_srand ( $ seed ) ; } $ rand = mt_rand ( $ min , $ max ) ; // unseed (random reseed) random generator mt_srand ( ) ; return $ rand ; }
Generates a random integer number between min and max.

@param int      $min  Lower bound (inclusive)
@param int      $max  Upper bound(inclusive)
@param null|int $seed Random generator seed

@return int|false A random integer value between min (or 0) and max (or 1, inclusive), or FALSE if max
is less than min.
@throws \InvalidArgumentException
Generates a random integer number between min and max .