-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtrait-singleton.php
More file actions
57 lines (49 loc) · 824 Bytes
/
Copy pathtrait-singleton.php
File metadata and controls
57 lines (49 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Trait Singleton
*
* @package WP_Github_User
*/
namespace WP_Github_User\Traits;
/**
* Trait Singleton
*/
trait Singleton {
/**
* Instance of class.
*
* @var $instance
*/
protected static $instance;
/**
* Create instance only once.
*
* @return static Current class object.
*/
final public static function get_instance() {
return isset( static::$instance )
? static::$instance
: static::$instance = new static();
}
/**
* Singleton constructor.
*/
final private function __construct() {
$this->init();
}
/**
* Action / Filters to be declare here.
*/
protected function init() {
}
/**
* Make private magic method wakeup.
*/
final private function __wakeup() {
}
/**
* Make private magic method clone.
*/
final private function __clone() {
}
}