35 lines
611 B
PHP
35 lines
611 B
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Singleton configuration class
|
||
|
|
* Register configuration directives with this class
|
||
|
|
*/
|
||
|
|
class Config {
|
||
|
|
private static $instance = null;
|
||
|
|
|
||
|
|
private $config = array();
|
||
|
|
|
||
|
|
private function __construct() {
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function getInstance() {
|
||
|
|
if (self::$instance === null) {
|
||
|
|
$clazz = __CLASS__;
|
||
|
|
self::$instance = new $clazz();
|
||
|
|
}
|
||
|
|
return self::$instance;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function register($key, $value) {
|
||
|
|
$this->config[$key] = $value;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function retrieve($key) {
|
||
|
|
if (isset($this->config[$key])) {
|
||
|
|
return $this->config[$key];
|
||
|
|
} else {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|