SimpleSAML_Configuration::getArrayizeString PHP Method

getArrayizeString() public method

If the configuration option is a string, it will be converted to an array with a single string
public getArrayizeString ( string $name, mixed $default = self::REQUIRED_OPTION ) : array
$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 array The option with the given name, or $default if the option isn't found and $default is specified.
    public function getArrayizeString($name, $default = self::REQUIRED_OPTION)
    {
        assert('is_string($name)');
        $ret = $this->getArrayize($name, $default);
        if ($ret === $default) {
            // the option wasn't found, or it matches the default value. In any case, return this value
            return $ret;
        }
        foreach ($ret as $value) {
            if (!is_string($value)) {
                throw new Exception($this->location . ': The option ' . var_export($name, true) . ' must be a string or an array of strings.');
            }
        }
        return $ret;
    }

Usage Example

 /**
  * @param SimpleSAML_Configuration $configuration
  * @param string                   $prefix
  *
  * @return array
  */
 private static function pluckConfiguration(SimpleSAML_Configuration $configuration, $prefix = '')
 {
     $extracted = array();
     // ported from
     // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1092
     if ($configuration->hasValue($prefix . 'keys')) {
         $extracted['keys'] = $configuration->getArray($prefix . 'keys');
     }
     // ported from
     // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1108
     if ($configuration->hasValue($prefix . 'certData')) {
         $extracted['certificateData'] = $configuration->getString($prefix . 'certData');
     }
     // ported from
     // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/lib/SimpleSAML/Configuration.php#L1119
     if ($configuration->hasValue($prefix . 'certificate')) {
         $extracted['certificateData'] = $configuration->getString($prefix . 'certificate');
     }
     // ported from
     // https://github.com/simplesamlphp/simplesamlphp/blob/3d735912342767d391297cc5e13272a76730aca0/modules/saml/lib/Message.php#L161
     if ($configuration->hasValue($prefix . 'certFingerprint')) {
         $extracted['certificateFingerprint'] = $configuration->getArrayizeString('certFingerprint');
     }
     $extracted['assertionEncryptionEnabled'] = $configuration->getBoolean('assertion.encryption', FALSE);
     if ($configuration->has('sharedKey')) {
         $extracted['sharedKey'] = $configuration->getString('sharedKey');
     }
     return $extracted;
 }
All Usage Examples Of SimpleSAML_Configuration::getArrayizeString