Created
December 17, 2013 21:11
-
-
Save drzippie/8012696 to your computer and use it in GitHub Desktop.
Settings: Key => value as Singleton
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Settings { | |
| var $values; | |
| final public static function getInstance() { | |
| static $aoInstance = null; | |
| if (is_null($aoInstance)) { | |
| $aoInstance = new Settings(); | |
| } | |
| return $aoInstance; | |
| } | |
| public function __construct() { | |
| $this->values = array( ); | |
| } | |
| function setValue($key, $val ) { | |
| $this->values [$key] = $val; | |
| return $this; | |
| } | |
| function getValue($key, $default = null) { | |
| return (isset($this->values[$key])) ? $this->values[$key] : $default; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment