hyperf-chat/app/Traits/StaticInstance.php

37 lines
486 B
PHP
Raw Normal View History

2021-05-21 22:56:42 +08:00
<?php
namespace App\Traits;
/**
* Trait StaticInstance
*
* @package App\Traits
*/
trait StaticInstance
{
private static $instance;
/**
* 获取单例
*
* @return static
*/
static public function getInstance()
{
2021-05-30 18:03:44 +08:00
if (is_null(static::$instance)) {
2021-06-04 19:55:20 +08:00
static::$instance = new static();
2021-05-21 22:56:42 +08:00
}
2021-05-30 18:03:44 +08:00
return static::$instance;
2021-05-21 22:56:42 +08:00
}
2021-06-29 17:30:43 +08:00
public function __construct()
{
}
public function __clone()
{
}
2021-05-21 22:56:42 +08:00
}