Returns a random integer between the provided min and max using random
bytes. Throws exception if min and max arguments have inconsistencies.

@param int $min
@param int $max
@throws \Exception
@return int
480301
public static function randomInt(int $min, int $max): int
    {
        if ($max <= $min) {
            throw new \Exception('Minimum equal or greater than maximum!');
        }
        if ($max < 0 || $min < 0) {
            throw new \Exception('Only positive integers supported for now!');
        }

        $difference = $max - $min;
        for ($power = 8; pow(2, $power) < $difference; $power = $power * 2) {
        }
        $powerExp = $power / 8;
        do {
            $randDiff = hexdec(bin2hex(self::randomBytes($powerExp)));
        } while ($randDiff > $difference);
        return $min + $randDiff;
    }
215855
public function deleteByRank(int $min, int $max): int
    {
        return $this->handle->zRemRangeByRank($this->name, $min , $max );
    }
525251
protected static function _rand($min, $max)
    {
        if (version_compare(PHP_VERSION, '7.0.0', 'ge')) {
            $value = random_int($min, $max);
        } else {
            $value = mt_rand($min, $max);
        }

        return $value;
    }
582168
protected function determineKey($min, $max)
    {
        $minGiven = ($min !== null);
        $maxGiven = ($max !== null);

        if (!$minGiven && !$maxGiven) {
            throw new InvalidArgumentException('You must specify a valid value for min, max or both.');
        }

        if ($minGiven && !$maxGiven) {
            // Open end range.
            return $min . ':';
        } elseif (!$minGiven && $maxGiven) {
            // Open start range.
            return ':' . $max;
        }

        if ($min === $max) {
            // Exact number.
            return $min;
        }

        // Full defined range.
        return $min . ':' . $max;
    }
1207589
public static function random_int(int $min=0, int $max=1) {
		if ($min > $max) {
			static::switcheroo($min, $max);
		}

		return \random_int($min, $max);
	}
1251880
public static function random($min, $max = null)
    {
        if (String::isEmpty($max) ||
            $max > getrandmax()) {
            $max = getrandmax();
        }

        return rand($min, $max);
    }
41810
public function rule_between( $key, $value, $min, $max )
	{
		return $this->rule_between_num( $key, strlen( $value ), $min, $max );
	}
59094
public static int randomIntBetween(int min, int max) {
    Random rand = new Random();
    return rand.nextInt((max - min) + 1) + min;
  }
1204232
public function generate($min = 0,$max = null)
    {
        if($max === null) {
            $max = $this->max;
        }
        
        if($min === null) {
            $min = $this->min;
        }
        
        
        return rand($min,$max);
    }
1164908
public static function numberLimit($val, $min, $max)
    {
        return ($val > $min ? ($val < $max ? $val : $max) : $min);
    }
595024
public int getInt(final int min, final int max) {
		return min(min, max) + getInt(abs(max - min));
	}
683738
public function between($min, $max)
    {
        $this->doCheck(function ($value) use ($min, $max) {
            $this->throwExceptionIfFalse(
                $this->isBetween($value, $min, $max),
                'Failed assertion that %s is between %s and %s', $value, $min, $max
            );
        });

        return $this;
    }
1196299
public static function getRandomInt($min = 0, $max = null)
    {
        $rand = null;

        if (function_exists('random_int')) {
            try {
                if (!isset($max)) {
                    $max = PHP_INT_MAX;
                }
                $rand = random_int($min, $max);
            } catch (Exception $e) {
                // If none of the crypto sources are available, an Exception will be thrown.
                $rand = null;
            }
        }

        if (!isset($rand)) {
            if (function_exists('mt_rand')) {
                if (!isset($max)) {
                    $max = mt_getrandmax();
                }
                $rand = mt_rand($min, $max);
            } else {
                if (!isset($max)) {
                    $max = getrandmax();
                }

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

        return $rand;
    }
579589
public function setRange($min, $max)
	{
		$min = filter_var($min, FILTER_VALIDATE_INT);
		$max = filter_var($max, FILTER_VALIDATE_INT);

		if ($min === false)
		{
			throw new InvalidArgumentException('Argument 1 passed to ' . __METHOD__ . ' must be an integer');
		}

		if ($max === false)
		{
			throw new InvalidArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be an integer');
		}

		if ($min > $max)
		{
			throw new InvalidArgumentException('Invalid range: min (' . $min . ') > max (' . $max . ')');
		}

		$this->vars['min'] = $min;
		$this->vars['max'] = $max;
	}
463410
public static function range($value, $min, $max)
    {
        return Validator::int()->between($min, $max)->validate($value);
    }
1153846
public function getInt($name, $min = null, $max = null)
    {
        $value = (int) $this($name);

        if (!is_null($min) && $value < $min) {
            return $min;
        } elseif (!is_null($max) && $value > $max) {
            return $max;
        }

        return $value;
    }
505103
public function countArray($min, $max = PHP_INT_MAX)
    {
        return $this->markErrorIf(!is_array($this->value)||count($this->value) < $min || count($this->value) > $max, false);
    }