优化代码
parent
4630ed8397
commit
c99b294edd
|
@ -11,6 +11,10 @@ trait StaticInstance
|
||||||
{
|
{
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单例
|
* 获取单例
|
||||||
*
|
*
|
||||||
|
@ -18,15 +22,14 @@ trait StaticInstance
|
||||||
*/
|
*/
|
||||||
static public function getInstance()
|
static public function getInstance()
|
||||||
{
|
{
|
||||||
if (!(self::$instance instanceof static)) {
|
if (is_null(static::$instance)) {
|
||||||
self::$instance = new static();
|
static::$instance = new static;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return static::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function __clone()
|
private function __clone()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue