-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingleton.php
More file actions
43 lines (38 loc) · 822 Bytes
/
Singleton.php
File metadata and controls
43 lines (38 loc) · 822 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
<?php
/**
* Copyright (C) Keraweb - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by Jory Hogeveen <info@keraweb.nl>
*
* @author Jory Hogeveen
* @link https://www.keraweb.nl/
* @package Keraweb
*/
namespace SyncEngine\WordPress\Service;
/**
* @package Keraweb
*/
abstract class Singleton
{
/**
* Already loaded singleton instances.
*/
private static $instances = array();
/**
* @return static
*/
public static function get_instance() {
$class = get_called_class();
if ( empty( self::$instances[ $class ] ) ) {
self::$instances[ $class ] = new $class();
}
return self::$instances[ $class ];
}
protected function __construct() {
// Nope.
}
private function __clone() {
// Nope.
}
}