public static function ints(int $min, int $max, int $n = 10) : array
    {
        if (($max - $min) < 0) {
            throw new InvalidArgumentException('Maximum cannot be'
                . ' less than minimum.');
        }

        if ($n < 1) {
            throw new InvalidArgumentException('Cannot generate less'
                . ' than 1 parameter.');
        }

        if ($n > ($max - $min + 1)) {
            throw new InvalidArgumentException('Cannot generate more'
                . ' unique integers than in range.');
        }

        $distribution = [];

        while (count($distribution) < $n) {
            $r = rand($min, $max);

            if (!in_array($r, $distribution)) {
                $distribution[] = $r;
            }
        }

        return $distribution;
    }
public static function ints(int $min, int $max, int $n = 10) : array
    {
        if (($max - $min) < 0) {
            throw new InvalidArgumentException('Maximum cannot be'
                . ' less than minimum.');
        }

        if ($n < 1) {
            throw new InvalidArgumentException('Cannot generate less'
                . ' than 1 parameter.');
        }

        if ($n > ($max - $min + 1)) {
            throw new InvalidArgumentException('Cannot generate more'
                . ' unique integers than in range.');
        }

        $distribution = [];

        while (count($distribution) < $n) {
            $r = rand($min, $max);

            if (!in_array($r, $distribution)) {
                $distribution[] = $r;
            }
        }

        return $distribution;
    }
public static function ints ( int $ min , int $ max , int $ n = 10 ) : array { if ( ( $ max - $ min ) < 0 ) { throw new InvalidArgumentException ( 'Maximum cannot be' . ' less than minimum.' ) ; } if ( $ n < 1 ) { throw new InvalidArgumentException ( 'Cannot generate less' . ' than 1 parameter.' ) ; } if ( $ n > ( $ max - $ min + 1 ) ) { throw new InvalidArgumentException ( 'Cannot generate more' . ' unique integers than in range.' ) ; } $ distribution = [ ] ; while ( count ( $ distribution ) < $ n ) { $ r = rand ( $ min , $ max ) ; if ( ! in_array ( $ r , $ distribution ) ) { $ distribution [ ] = $ r ; } } return $ distribution ; }
Generate a random unique integer distribution.

@param int $min
@param int $max
@param int $n
@throws \InvalidArgumentException
@return int[]
Generate a random unique integer distribution .