Skip to content

Instantly share code, notes, and snippets.

@geminorum
Forked from chrisguitarguy/Foo.php
Last active August 29, 2015 14:11
Show Gist options
  • Save geminorum/c90bf16c8f86a7f90134 to your computer and use it in GitHub Desktop.
Save geminorum/c90bf16c8f86a7f90134 to your computer and use it in GitHub Desktop.
<?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