34 lines
527 B
PHP
34 lines
527 B
PHP
<?php
|
|
|
|
namespace inContact;
|
|
/**
|
|
* Cecha singleton
|
|
*
|
|
* @link https://krzysztof-turek.com
|
|
*
|
|
* @package tylkofotografia.pl
|
|
* @version 0.2
|
|
*/
|
|
trait Singleton
|
|
{
|
|
private static $instances = [];
|
|
|
|
protected function __construct()
|
|
{
|
|
}
|
|
|
|
final protected function __clone()
|
|
{
|
|
}
|
|
|
|
public static function getInstance()
|
|
{
|
|
|
|
$class = get_called_class();
|
|
|
|
if (!isset($instances[$class])) {
|
|
$instances[$class] = new $class;
|
|
}
|
|
return $instances[$class];
|
|
}
|
|
} |