initial commit
This commit is contained in:
34
inc/classes/inContact/Singleton.php
Normal file
34
inc/classes/inContact/Singleton.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user