diff options
author | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-08-05 14:33:41 +0200 |
---|---|---|
committer | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-08-05 14:33:41 +0200 |
commit | 3c7e84673055c61aa7addde9618ee190aeef0429 (patch) | |
tree | e1eb189cc577b9c6eb684c6c2e44a132974e88e2 | |
parent | bfc70e12e60e95f4e786d03892d753a4052ca79f (diff) | |
download | simplesamlphp-3c7e84673055c61aa7addde9618ee190aeef0429.zip simplesamlphp-3c7e84673055c61aa7addde9618ee190aeef0429.tar.gz simplesamlphp-3c7e84673055c61aa7addde9618ee190aeef0429.tar.bz2 |
Reformat SimpleSAML_Store.
-rw-r--r-- | lib/SimpleSAML/Store.php | 160 |
1 files changed, 82 insertions, 78 deletions
diff --git a/lib/SimpleSAML/Store.php b/lib/SimpleSAML/Store.php index 0a95acf..0b3b8bd 100644 --- a/lib/SimpleSAML/Store.php +++ b/lib/SimpleSAML/Store.php @@ -1,87 +1,91 @@ <?php + /** * Base class for data stores. * * @package SimpleSAMLphp */ -abstract class SimpleSAML_Store { - - /** - * Our singleton instance. - * - * 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 - */ - private static $instance; - - - /** - * Retrieve our singleton instance. - * - * @return SimpleSAML_Store|boolean The data store, or false if it isn't enabled. - */ - public static function getInstance() { - - if (self::$instance !== NULL) { - return self::$instance; - } - - $config = SimpleSAML_Configuration::getInstance(); - $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. */ - self::$instance = FALSE; - break; - case 'memcache': - self::$instance = new SimpleSAML_Store_Memcache(); - break; - case 'sql': - self::$instance = new SimpleSAML_Store_SQL(); - break; - default: - /* Datastore from module. */ - $className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store'); - self::$instance = new $className(); - } - - return self::$instance; - } - - - /** - * Retrieve a value from the data store. - * - * @param string $type The data type. - * @param string $key The 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. - * @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. - */ - abstract public function delete($type, $key); +abstract class SimpleSAML_Store +{ + + /** + * Our singleton instance. + * + * 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 + */ + private static $instance; + + + /** + * Retrieve our singleton instance. + * + * @return SimpleSAML_Store|boolean The data store, or false if it isn't enabled. + */ + public static function getInstance() + { + + if (self::$instance !== null) { + return self::$instance; + } + + $config = SimpleSAML_Configuration::getInstance(); + $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 + self::$instance = false; + break; + case 'memcache': + self::$instance = new SimpleSAML_Store_Memcache(); + break; + case 'sql': + self::$instance = new SimpleSAML_Store_SQL(); + break; + default: + // datastore from module + $className = SimpleSAML_Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store'); + self::$instance = new $className(); + } + + return self::$instance; + } + + + /** + * Retrieve a value from the data store. + * + * @param string $type The data type. + * @param string $key The 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. + * @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. + */ + abstract public function delete($type, $key); } |