Skip to content

Instantly share code, notes, and snippets.

@hatyuki
Created October 15, 2009 03:08
Show Gist options
  • Save hatyuki/210629 to your computer and use it in GitHub Desktop.
Save hatyuki/210629 to your computer and use it in GitHub Desktop.
<?php // vim: ts=4 sts=4 sw=4
class AppRegistry
{
private static $instance;
private $registry = array( );
static function instance ( )
{
if ( !isset(self::$instance) ) {
self::$instance = new self( );
}
return self::$instance;
}
private function __construct ( ) { }
function get ($key)
{
return array_key_exists($key, $this->registry)
? $this->registry[$key]
: null;
}
function set ($key, $value)
{
$this->registry[$key] = $value;
return $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment