-
-
Save geminorum/c90bf16c8f86a7f90134 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Foo | |
| { | |
| private $name; | |
| private static $defaultInstance = null; | |
| /** | |
| * Public constructor: create as many instance as you want | |
| */ | |
| public function __construct($name) | |
| { | |
| $this->name = $name; | |
| } | |
| public static function getDefaultInstance() | |
| { | |
| if (null === self::$defaultInstance) { | |
| self::$defaultInstance = new self('default'); | |
| } | |
| return self::$defaultInstance; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment