6 * simple implementation of generic singleton
7 * for all classes, which allows additional instances
15 * @param $strClass - the class we want an instance from
17 * @throws UnexpectedParameterTypeException - if given parameter is not a string
18 * @throws \Exception - if given class do not exists
20 * @return (object) - an instance of the given classname
22 * get a reference to the instance of the given class.
23 * if instance do not exists, create one. after creation
24 * always return reference to this reference
27 static function getInstance($strClass) {
29 if(!is_string($strClass))
30 throw new UnexpectedParameterTypeException('string', $strClass);
32 if(!class_exists($strClass))
33 throw new \Exception ("class do not exists: $strClass");
35 static $arrObjectList = array();
37 if(!isset($arrObjectList[$strClass]))
38 $arrObjectList[$strClass] = new $strClass();
40 return $arrObjectList[$strClass];