Singleton Design Pattern

Hi PHP Gurus!!

Can you please check and confirm if the following code snippet qualifies for a full or partial singleton design pattern?


<?php
Class Hello
{
  private static $MyObject = null;

 static public function listActiveUsers(){

  $userObj = self::User();

 // code here....

 }

 static private function User(){

    if(is_object(self::$MyObject)){
      return self::$MyObject
   }

   return self::$MyObject = new User();

 }

}


?>

Thanks in advance

TBH, I have no idea what you mean by “full” and “partial” singleton, but the code you’re showing does adhere to the singleton pattern, yes.

Thanks for confirming that.

Singleton pattern is very common, you don’t need to worry about it.