DDDBL 2.0
 All Classes Namespaces Files Functions Variables
Singleton.class.php
Go to the documentation of this file.
1 <?php
2 
3 namespace DDDBL;
4 
12 class Singleton {
13 
27  static function getInstance($strClass) {
28 
29  if(!is_string($strClass))
30  throw new UnexpectedParameterTypeException('string', $strClass);
31 
32  if(!class_exists($strClass))
33  throw new \Exception ("class do not exists: $strClass");
34 
35  static $arrObjectList = array();
36 
37  if(!isset($arrObjectList[$strClass]))
38  $arrObjectList[$strClass] = new $strClass();
39 
40  return $arrObjectList[$strClass];
41 
42  }
43 
44 }