17 lines
291 B
PHP
17 lines
291 B
PHP
|
<?php
|
||
|
|
||
|
namespace DarksLight2\Traits;
|
||
|
|
||
|
trait Singleton
|
||
|
{
|
||
|
private static self $instance;
|
||
|
|
||
|
public static function getInstance(...$args): self
|
||
|
{
|
||
|
if(!isset(self::$instance)) {
|
||
|
self::$instance = new self(...$args);
|
||
|
}
|
||
|
|
||
|
return self::$instance;
|
||
|
}
|
||
|
}
|