Skip to content

Instantly share code, notes, and snippets.

@devlubinets
Created October 6, 2021 16:47
Show Gist options
  • Save devlubinets/90f1bba4ba5784494a54762de89ded37 to your computer and use it in GitHub Desktop.
Save devlubinets/90f1bba4ba5784494a54762de89ded37 to your computer and use it in GitHub Desktop.
Пример метода создания объекта по паттерну Singletone
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