diff --git "a/include/class-generic\\Singleton.php" "b/include/class-generic\\Singleton.php" index b5c62fc..c2b9c3a 100644 --- "a/include/class-generic\\Singleton.php" +++ "b/include/class-generic\\Singleton.php" @@ -1,38 +1,55 @@ . # generic stuff namespace generic; +/** + * A singleton gives a getInstance() method + */ trait Singleton { + /** + * Get an instance of this class + * + * @return self + */ public static function getInstance() { static $instance; if( ! $instance ) { $instance = static::create(); } return $instance; } + /** + * Function to be overrided to create an instance of this class + * + * @return self + */ protected static function create() { - throw new \Exception('must override'); + throw new \Exception( 'must override' ); } + /** + * Throw an usage error + */ public static function throwWrongUsage() { - throw new \Exception('wrong usage'); + throw new \Exception( 'wrong usage' ); } + }