Skip to content
Snippets Groups Projects
Commit 3c7e8467 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Reformat SimpleSAML_Store.

parent bfc70e12
No related branches found
No related tags found
No related merge requests found
<?php <?php
/** /**
* Base class for data stores. * Base class for data stores.
* *
* @package SimpleSAMLphp * @package SimpleSAMLphp
*/ */
abstract class SimpleSAML_Store { abstract class SimpleSAML_Store
{
/**
* Our singleton instance. /**
* * Our singleton instance.
* This is false if the data store isn't enabled, and null if we haven't attempted to initialize it. *
* * This is false if the data store isn't enabled, and null if we haven't attempted to initialize it.
* @var SimpleSAML_Store|boolean|null *
*/ * @var SimpleSAML_Store|boolean|null
private static $instance; */
private static $instance;
/**
* Retrieve our singleton instance. /**
* * Retrieve our singleton instance.
* @return SimpleSAML_Store|boolean The data store, or false if it isn't enabled. *
*/ * @return SimpleSAML_Store|boolean The data store, or false if it isn't enabled.
public static function getInstance() { */
public static function getInstance()
if (self::$instance !== NULL) { {
return self::$instance;
} if (self::$instance !== null) {
return self::$instance;
$config = SimpleSAML_Configuration::getInstance(); }
$storeType = $config->getString('store.type', NULL);
if ($storeType === NULL) { $config = SimpleSAML_Configuration::getInstance();
$storeType = $config->getString('session.handler', 'phpsession'); $storeType = $config->getString('store.type', null);
} if ($storeType === null) {
$storeType = $config->getString('session.handler', 'phpsession');
switch ($storeType) { }
case 'phpsession':
/* We cannot support advanced features with the PHP session store. */ switch ($storeType) {
self::$instance = FALSE; case 'phpsession':
break; // we cannot support advanced features with the PHP session store
case 'memcache': self::$instance = false;
self::$instance = new SimpleSAML_Store_Memcache(); break;
break; case 'memcache':
case 'sql': self::$instance = new SimpleSAML_Store_Memcache();
self::$instance = new SimpleSAML_Store_SQL(); break;
break; case 'sql':
default: self::$instance = new SimpleSAML_Store_SQL();
/* Datastore from module. */ break;
$className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store'); default:
self::$instance = new $className(); // datastore from module
} $className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
self::$instance = new $className();
return self::$instance; }
}
return self::$instance;
}
/**
* Retrieve a value from the data store.
* /**
* @param string $type The data type. * Retrieve a value from the data store.
* @param string $key The key. *
* @return mixed|null The value. * @param string $type The data type.
*/ * @param string $key The key.
abstract public function get($type, $key); *
* @return mixed|null The value.
*/
/** abstract public function get($type, $key);
* Save a value to the data store.
*
* @param string $type The data type. /**
* @param string $key The key. * Save a value to the data store.
* @param mixed $value The value. *
* @param int|null $expire The expiration time (unix timestamp), or null if it never expires. * @param string $type The data type.
*/ * @param string $key The key.
abstract public function set($type, $key, $value, $expire = NULL); * @param mixed $value The value.
* @param int|null $expire The expiration time (unix timestamp), or null if it never expires.
*/
/** abstract public function set($type, $key, $value, $expire = null);
* Delete a value from the data store.
*
* @param string $type The data type. /**
* @param string $key The key. * Delete a value from the data store.
*/ *
abstract public function delete($type, $key); * @param string $type The data type.
* @param string $key The key.
*/
abstract public function delete($type, $key);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment