1 <?php
2 /**
3 * Singleton.php
4 *
5 * @author Elvyrra SAS
6 * @license http://rem.mit-license.org/ MIT
7 */
8
9 namespace Hawk;
10
11 /**
12 * This class describes the general behavior of singleton classes, sucha as Request, Response, ...
13 *
14 * @package Core
15 */
16 class Singleton{
17 /**
18 * The singleton instance
19 */
20 protected static $instance;
21
22 /**
23 * The constrcutor
24 */
25 protected function __construct(){
26 }
27
28 /**
29 * Get the singleton instance
30 */
31 public static function getInstance(){
32 if(!isset(static::$instance)) {
33 $class = get_called_class();
34 static::$instance = new $class();
35 }
36
37 return static::$instance;
38 }
39 }