SimpleSAML_Configuration::getInteger PHP Method

getInteger() public method

An exception will be thrown if this option isn't an integer, or if this option isn't found, and no default value is given.
public getInteger ( string $name, mixed $default = self::REQUIRED_OPTION ) : integer | mixed
$name string The name of the option.
$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 getInteger($name, $default = self::REQUIRED_OPTION)
    {
        assert('is_string($name)');
        $ret = $this->getValue($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 (!is_int($ret)) {
            throw new Exception($this->location . ': The option ' . var_export($name, true) . ' is not a valid integer value.');
        }
        return $ret;
    }

Usage Example

コード例 #1
0
 /**
  * Initializes this discovery service.
  *
  * The constructor does the parsing of the request. If this is an invalid request, it will throw an exception.
  *
  * @param array  $metadataSets Array with metadata sets we find remote entities in.
  * @param string $instance The name of this instance of the discovery service.
  */
 public function __construct(array $metadataSets, $instance)
 {
     parent::__construct($metadataSets, $instance);
     $this->discoconfig = SimpleSAML_Configuration::getConfig('module_discopower.php');
     $this->cdcDomain = $this->discoconfig->getString('cdc.domain', null);
     if ($this->cdcDomain !== null && $this->cdcDomain[0] !== '.') {
         // ensure that the CDC domain starts with a dot ('.') as required by the spec
         $this->cdcDomain = '.' . $this->cdcDomain;
     }
     $this->cdcLifetime = $this->discoconfig->getInteger('cdc.lifetime', null);
 }
All Usage Examples Of SimpleSAML_Configuration::getInteger