PluginProbe
Independent Analytics – WordPress Analytics Plugin / 1.24.0
Independent Analytics – WordPress Analytics Plugin v1.24.0
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / Utils / Singleton.php
Singleton.php
57 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IAWP_SCOPED\IAWP\Utils;
4
5 trait Singleton
6 {
7 /**
8 * Singleton Instance
9 *
10 * @var mixed
11 */
12 private static $instance = null;
13 /**
14 * Private Constructor
15 *
16 * We can't use the constructor to create an instance of the class
17 *
18 * @return void
19 */
20 private function __construct()
21 {
22 // Don't do anything, we don't want to be initialized
23 }
24 /**
25 * Get the singleton instance
26 *
27 * @return self
28 */
29 public static function getInstance() : self
30 {
31 if (\is_null(self::$instance)) {
32 self::$instance = new self();
33 }
34 return self::$instance;
35 }
36 /**
37 * Private clone method to prevent cloning of the instance of the
38 * Singleton instance.
39 *
40 * @return void
41 */
42 private function __clone()
43 {
44 // Don't do anything, we don't want to be cloned
45 }
46 /**
47 * Private unserialize method to prevent unserializing of the Singleton
48 * instance.
49 *
50 * @return void
51 */
52 public function __wakeup()
53 {
54 // Don't do anything, we don't want to be unserialized
55 }
56 }
57