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