diff options
| author | winter | 2024-12-09 21:31:54 +0000 |
|---|---|---|
| committer | winter | 2024-12-09 21:31:54 +0000 |
| commit | 4c7bde1400820f36caf8b2a5374007384c3018f3 (patch) | |
| tree | 83ed26ff368117b8e392f7bc28736482077fc2f4 /Digitigrade/Singleton.php | |
| parent | 50edbd3907c26a2d4d616421de9bb51a4d083c1b (diff) | |
rename to Digitigrade / PawPub
:3
Diffstat (limited to 'Digitigrade/Singleton.php')
| -rw-r--r-- | Digitigrade/Singleton.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Digitigrade/Singleton.php b/Digitigrade/Singleton.php new file mode 100644 index 0000000..23b2e78 --- /dev/null +++ b/Digitigrade/Singleton.php @@ -0,0 +1,18 @@ +<?php +namespace Digitigrade; + +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 |
