I have a class with the following structure:
class Something
{
private static $_instance = null;
final public function __construct()
{
//(...)
try
{
//(...)
}
catch(Exception $e)
{
//(...)
}
}
public static function getInstance()
{
if (self::$_instance === null)
{
self::$_instance = new self;
}
return self::$_instance;
}
private function __clone()
{
//empty
}
} //end of class
Is it correct and precise to say that, on this class, we have applied a Singleton Design Pattern?
Thanks a lot in advance.
No. For Singelton, it’s required that constructor is declared private and class has ‘getter’ method, most common getInstance(), that you’ve already implemented.