freenet-router |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?php
namespace Phem\Core;
abstract class Singleton extends Object
{
protected static $instances;
protected function __construct()
{
}
protected function __clone()
{
}
public function __wakeup()
{
throw new CoreException("Cannot unserialize singleton");
}
public static function getInstance()
{
$cls = get_called_class(); // late-static-bound class name
if (!isset(static::$instances))
{
static::$instances = new Collection();
}
if (!(static::$instances->containsKey($cls)))
{
self::$instances->put($cls,new static);
}
return self::$instances->get($cls);
}
}