refactoring the ternary operator in the constructor to make the code more readable and to remove the potential for an orphaned object

fixes #39
This commit is contained in:
Tom McFarlin 2013-05-09 21:19:16 -04:00
parent 8afcf2547f
commit 0d8277d858
1 changed files with 8 additions and 1 deletions

View File

@ -59,7 +59,14 @@ class PluginName {
* @return PluginName A single instance of this class.
*/
public function get_instance() {
return null == self::$instance ? new self : self::$instance;
// If the single instance hasn't been set, set it now.
if( null == self::$instance ) {
self::$instance = new self;
} // end if
return self::$instance;
} // end get_instance;
/**