summaryrefslogtreecommitdiff
path: root/src/lib/Singleton.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Singleton.class.php')
-rw-r--r--src/lib/Singleton.class.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/Singleton.class.php b/src/lib/Singleton.class.php
new file mode 100644
index 0000000..4eb3bb3
--- /dev/null
+++ b/src/lib/Singleton.class.php
@@ -0,0 +1,12 @@
+<?php
+
+abstract class Singleton {
+ private static $obj;
+ public static function getInstance() {
+ if (!isset(self::$obj)) {
+ $class = get_called_class();
+ self::$obj = new $class;
+ }
+ return self::$obj;
+ }
+}