]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 12 Aug 2021 13:48:45 +0000 (15:48 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 12 Aug 2021 13:48:45 +0000 (15:48 +0200)
- $infoInstance should not be NULL or anything beside an instance of
  ShareableInfo

Signed-off-by: Roland Häder <roland@mxchange.org>
application/hub/classes/handler/package/class_NetworkPackageHandler.php

index 888aeb3cd1b9b0627bf8d88611fef1ed063efd45..5c83d26d47e42e685f22a341ad07ffe601e4ad0f 100644 (file)
@@ -36,6 +36,7 @@ use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Factory\Registry\Socket\SocketRegistryFactory;
 use Org\Mxchange\CoreFramework\Feature\FrameworkFeature;
+use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Socket\InvalidSocketException;
@@ -49,6 +50,7 @@ use Org\Mxchange\CoreFramework\Visitor\Visitor;
 use \BadMethodCallException;
 use \InvalidArgumentException;
 use \Iterator;
+use \LogicException;
 use \UnexpectedValueException;
 
 /**
@@ -719,7 +721,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $infoInstance = $this->getRegistryInstance()->getInfoInstanceFromPackageInstance($packageInstance);
 
                // Test helper instance
-               assert($infoInstance instanceof ShareableInfo);
+               if (is_null($infoInstance)) {
+                       // Throw NPE
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } elseif (!($infoInstance instanceof ShareableInfo)) {
+                       // Not the right instance
+                       throw new LogicException(sprintf('infoInstance[]=%s is not an instance of %s', gettype($infoInstance), ShareableInfo::class));
+               }
 
                // Get helper instance
                $helperInstance = $infoInstance->getHelperInstance();