mirror of
https://github.com/openvk/chandler.git
synced 2025-03-31 21:43:59 +03:00
30 lines
488 B
PHP
30 lines
488 B
PHP
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
namespace Chandler\Patterns;
|
|
|
|
/**
|
|
* @package Chandler\Patterns
|
|
*/
|
|
trait TSimpleSingleton
|
|
{
|
|
/**
|
|
* @var static
|
|
*/
|
|
private static $instance;
|
|
|
|
/**
|
|
* @return static
|
|
*/
|
|
public static function i(): self
|
|
{
|
|
if (is_null(static::$instance)) {
|
|
return static::$instance = new static();
|
|
} else {
|
|
return static::$instance;
|
|
}
|
|
}
|
|
|
|
private final function __construct() {}
|
|
}
|