SimpleSAML_Configuration::getIntegerRange PHP Method

getIntegerRange() public method

An exception will be thrown if: - the option isn't an integer - the option isn't found, and no default value is given - the value is outside of the allowed range
public getIntegerRange ( string $name, integer $minimum, integer $maximum, mixed $default = self::REQUIRED_OPTION ) : integer | mixed
$name string The name of the option.
$minimum integer The smallest value which is allowed.
$maximum integer The largest value which is allowed.
$default mixed A default value which will be returned if the option isn't found. The option will be required if this parameter isn't given. The default value can be any value, including null.
return integer | mixed The option with the given name, or $default if the option isn't found and $default is specified.
    public function getIntegerRange($name, $minimum, $maximum, $default = self::REQUIRED_OPTION)
    {
        assert('is_string($name)');
        assert('is_int($minimum)');
        assert('is_int($maximum)');
        $ret = $this->getInteger($name, $default);
        if ($ret === $default) {
            // the option wasn't found, or it matches the default value. In any case, return this value
            return $ret;
        }
        if ($ret < $minimum || $ret > $maximum) {
            throw new Exception($this->location . ': Value of option ' . var_export($name, true) . ' is out of range. Value is ' . $ret . ', allowed range is [' . $minimum . ' - ' . $maximum . ']');
        }
        return $ret;
    }