openstamanager/lib/classes/Util/Singleton.php

41 lines
678 B
PHP

<?php
namespace Util;
/**
* @since 2.3
*/
abstract class Singleton
{
/** @var \Util\Singleton Oggetti istanziati */
protected static $instance = [];
protected function __construct()
{
}
/**
* Restituisce l'istanza della classe in oggetto.
*
* @return Singleton
*/
public static function getInstance()
{
$class = get_called_class(); // late-static-bound class name
if (!isset(self::$instance[$class])) {
self::$instance[$class] = new static();
}
return self::$instance[$class];
}
private function __clone()
{
}
private function __wakeup()
{
}
}