Skip to content

Instantly share code, notes, and snippets.

@drzippie
Created December 17, 2013 21:11
Show Gist options
  • Select an option

  • Save drzippie/8012696 to your computer and use it in GitHub Desktop.

Select an option

Save drzippie/8012696 to your computer and use it in GitHub Desktop.
Settings: Key => value as Singleton
<?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