aboutsummaryrefslogtreecommitdiffhomepage
path: root/WpfTest/Singleton.php
diff options
context:
space:
mode:
authorwinter2024-12-07 21:44:42 +0000
committerwinter2024-12-07 21:44:42 +0000
commita84232811dadccf7047424f27340a7f9847bedff (patch)
treea6a0823c8b9485b6a5b60ea7ae854f9511a6ae1e /WpfTest/Singleton.php
parente1ad307b531c27ec6bfaf8b4d018991b0d4a78f3 (diff)
many many changes but actors are loaded from db now
Diffstat (limited to 'WpfTest/Singleton.php')
-rw-r--r--WpfTest/Singleton.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/WpfTest/Singleton.php b/WpfTest/Singleton.php
new file mode 100644
index 0000000..b365e1e
--- /dev/null
+++ b/WpfTest/Singleton.php
@@ -0,0 +1,18 @@
+<?php
+namespace WpfTest;
+
+abstract class Singleton {
+ private static array $instances;
+ protected function __construct() {
+ }
+ /**
+ * @return static the singleton instance
+ */
+ public static function getInstance() {
+ if (!isset(self::$instances[static::class])) {
+ //error_log('making a new ' . static::class);
+ self::$instances[static::class] = new static();
+ }
+ return self::$instances[static::class];
+ }
+} \ No newline at end of file