Created
October 15, 2009 03:08
-
-
Save hatyuki/210629 to your computer and use it in GitHub Desktop.
This file contains 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 // 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