Created
October 6, 2021 16:47
-
-
Save devlubinets/90f1bba4ba5784494a54762de89ded37 to your computer and use it in GitHub Desktop.
Пример метода создания объекта по паттерну Singletone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function getInstance(): Singleton | |
{ | |
$cls = static::class; | |
if (!isset(self::$instances[$cls])) { | |
self::$instances[$cls] = new static(); | |
} | |
return self::$instances[$cls]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment