Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
singletontrait.php
1<?php
2
4
5trait SingletonTrait
6{
10 protected static $instance = null;
11
15 public static function getInstance()
16 {
17 if (static::$instance === null)
18 {
19 static::$instance = new static();
20 }
21
22 return static::$instance;
23 }
24
25
26 protected function __construct(){}
27
31 public function __wakeup()
32 {
33 throw new BaseException("Trying to wake singleton up");
34 }
35 protected function __clone(){}
36}