From 0d8277d8580278492bbc4b880834314d8114aa44 Mon Sep 17 00:00:00 2001 From: Tom McFarlin Date: Thu, 9 May 2013 21:19:16 -0400 Subject: [PATCH] refactoring the ternary operator in the constructor to make the code more readable and to remove the potential for an orphaned object fixes #39 --- plugin-boilerplate/plugin.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin-boilerplate/plugin.php b/plugin-boilerplate/plugin.php index 6844614..c281716 100644 --- a/plugin-boilerplate/plugin.php +++ b/plugin-boilerplate/plugin.php @@ -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; /**