summaryrefslogtreecommitdiff
path: root/src/Singleton.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Singleton.php')
-rw-r--r--src/Singleton.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Singleton.php b/src/Singleton.php
new file mode 100644
index 0000000..b4d4598
--- /dev/null
+++ b/src/Singleton.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace App;
+
+trait Singleton
+{
+ private static self $instance;
+
+ public static function getInstance(): self
+ {
+ if (! isset(self::$instance)) {
+ self::$instance = new self();
+ }
+
+ return self::$instance;
+ }
+}