* @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;
}