jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Core/] [Singleton.php] - Rev 2

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);
    }

}

Powered by WebSVN 2.2.1