Skip to content

Instantly share code, notes, and snippets.

@delboy1978uk
Created July 18, 2019 13:18
Show Gist options
  • Save delboy1978uk/4f636fa33c60b40c82b0b56c8b3e03e0 to your computer and use it in GitHub Desktop.
Save delboy1978uk/4f636fa33c60b40c82b0b56c8b3e03e0 to your computer and use it in GitHub Desktop.
<?php
class Singleton
{
protected static $instance;
private function __construct(){}
private function __clone(){}
public static function getInstance(): self
{
if (!static::$instance) {
static::$instance = new self;
}
return static::$instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment