aboutsummaryrefslogtreecommitdiffhomepage
path: root/WpfTest/Singleton.php
blob: b365e1e85fb5ef5bf0b3f9d71d535c3f09ce7f65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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];
    }
}