From 4c2f00bb06d8797000a01f685471c220510b5c3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 14 May 2012 20:18:23 +0000 Subject: [PATCH] Refactured 'BaseRegistry::getInstance()' a little --- inc/classes/main/registry/class_BaseRegistry.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/inc/classes/main/registry/class_BaseRegistry.php b/inc/classes/main/registry/class_BaseRegistry.php index 84b6d63b..73c60cf3 100644 --- a/inc/classes/main/registry/class_BaseRegistry.php +++ b/inc/classes/main/registry/class_BaseRegistry.php @@ -168,20 +168,15 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable { * @throws NullPointerException If the requested key is not found */ public function getInstance ($instanceKey) { - // By default the instance is not in registry - $objectInstance = NULL; - // Is the instance there? - if ($this->instanceExists($instanceKey)) { - $objectInstance = $this->instanceRegistry[$instanceKey]; - } // END - if - - // Still not fetched? - if (is_null($objectInstance)) { + if (!$this->instanceExists($instanceKey)) { // This might happen if a non-registered key was requested throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } // END - if + // Get the instance + $objectInstance = $this->instanceRegistry[$instanceKey]; + // Return the result return $objectInstance; } -- 2.39.5