| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/Engineering/V1/iimec/wp-content/themes/annotum-base/functions/ |
Upload File : |
<?php
/**
* Globally keep around instances without polluting the global namespace.
* Get and set instances with a keyword.
* Also allows for easy overrides by re-keeping something with the same key.
* Replaced keys must be an instance of the original.
*/
class Anno_Keeper {
protected static $instances = array();
public static function keep($key, $instance) {
if (isset(self::$instances[$key]) && !($instance instanceof self::$instances[$key])) {
throw new Exception('If you\'re going to replace an instance that already exists, the new instance must be an instanceof the original class, so that methods may safely be called.', 1);
}
self::$instances[$key] = $instance;
return self::$instances[$key];
}
public static function retrieve($key) {
if (!isset(self::$instances[$key])) {
throw new Exception($key.' hasn\'t been set yet with ::keep()', 1);
}
return self::$instances[$key];
}
public function discard($key) {
unset(self::$instances[$key]);
}
}
?>