Guest User

Untitled

a guest
Jul 23rd, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. <?php
  2.  
  3. class SomeClass {
  4.     private static $instance;
  5.  
  6.     public static function getInstance() {
  7.         if (!$this->instance) {
  8.             return $this->instance = new static;
  9.         }
  10.  
  11.         return this->instance;
  12.     }
  13. }
  14.  
  15. // Could be:
  16.  
  17. class Container {
  18.     public static saved function getInstance() {
  19.         return new static;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment