]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/resolver/command/class_BaseCommandResolver.php
Continued:
[core.git] / framework / main / classes / resolver / command / class_BaseCommandResolver.php
index 9d5177aa4575fe5eb5c4b5e3bc1c55c52d86f84b..2a231dc0ee4e98c0fcda71db7f27b1fd268d795a 100644 (file)
@@ -6,10 +6,11 @@ namespace Org\Mxchange\CoreFramework\Resolver\Command;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Command\Commandable;
 use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Resolver\BaseResolver;
-use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
+use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
 
 // Import SPL stuff
 use \InvalidArgumentException;
@@ -20,7 +21,7 @@ use \UnexpectedValueException;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -81,7 +82,7 @@ abstract class BaseCommandResolver extends BaseResolver {
         * @throws      InvalidCommandException         Thrown if even the default
         *                                                                              command class is missing (bad!)
         */
-       protected function loadCommand ($commandName) {
+       protected function loadCommand (string $commandName) {
                // Init command instance
                $commandInstance = NULL;
 
@@ -103,7 +104,7 @@ abstract class BaseCommandResolver extends BaseResolver {
                }
 
                // Initiate the command
-               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
+               $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), [$this]);
 
                // Return the result
                return $commandInstance;
@@ -142,7 +143,7 @@ abstract class BaseCommandResolver extends BaseResolver {
                // And validate it
                if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) {
                        // This command has an invalid instance!
-                       throw new UnexpectedValueException(sprintf('commandInstance for commandName=%s is not object (%s) or does not implement Commandable.', $commandName, gettype($commandInstance)), self::EXCEPTION_INVALID_COMMAND);
+                       throw new UnexpectedValueException(sprintf('commandInstance for commandName=%s is not object (%s) or does not implement Commandable.', $commandName, gettype($commandInstance)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
                }
 
                // Set last command
@@ -167,10 +168,10 @@ abstract class BaseCommandResolver extends BaseResolver {
                // Is a action set?
                if (empty($namespace)) {
                        // Then thrown an exception here
-                       throw new InvalidArgumentException('Parameter "namespace" is empty');
+                       throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                } elseif (empty($commandName)) {
                        // Then thrown an exception here
-                       throw new InvalidArgumentException('Parameter "commandName" is empty');
+                       throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
 
                // Initiate the instance variable
@@ -211,10 +212,10 @@ abstract class BaseCommandResolver extends BaseResolver {
                // Is namespace and command name set?
                if (empty($namespace)) {
                        // Then thrown an exception here
-                       throw new InvalidArgumentException('Parameter "namespace" is empty');
+                       throw new InvalidArgumentException('Parameter "namespace" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                } elseif (empty($commandName)) {
                        // Then thrown an exception here
-                       throw new InvalidArgumentException('Parameter "commandName" is empty');
+                       throw new InvalidArgumentException('Parameter "commandName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
 
                // By default nothing shall be valid