mercredi 19 avril 2017

How to call atribute method from auto initialized static function

I have a class that have a public static attribute, this attribute is getting initialized by automathic constructor with the getInstance trick, my question is how can I call the attribute alredy initialized and call one of his methods? this is not working botLogger::getInstance()->$log->info(date("Y-m-d H:i:s");

class template
{
   public static $log;
   private static $instance;

   private function __construct()
   {
       self::$log = Logger::getLogger('myLogger');
   }

   public static function getInstance()
   {
       if (is_null(self::$instance)) {
           self::$instance = new self();
       }
       return self::$instance;
   }

       public static function startLogger()
   {
       botLogger::getInstance()->$log->info(date("Y-m-d H:i:s");
   }

}






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire