Created
July 18, 2019 13:18
-
-
Save delboy1978uk/4f636fa33c60b40c82b0b56c8b3e03e0 to your computer and use it in GitHub Desktop.
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
<?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