]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/resolver/action/class_BaseActionResolver.php
Continued:
[core.git] / framework / main / classes / resolver / action / class_BaseActionResolver.php
index 30c2b4bcd875c618886ccdf759e60740d005e93e..e65854accfaf02a47cc0f2ef2b77fc3d95dc9521 100644 (file)
@@ -3,8 +3,9 @@
 namespace Org\Mxchange\CoreFramework\Resolver\Action;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Resolver\BaseResolver;
+use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 // Import SPL stuff
 use \InvalidArgumentException;
@@ -43,7 +44,7 @@ abstract class BaseActionResolver extends BaseResolver {
         * @param       $className      Name of the class
         * @return      void
         */
-       protected function __construct ($className) {
+       protected function __construct (string $className) {
                // Call parent constructor
                parent::__construct($className);
        }
@@ -54,8 +55,8 @@ abstract class BaseActionResolver extends BaseResolver {
         * @param       $actionName     Last validated action name
         * @return      void
         */
-       protected final function setActionName ($actionName) {
-               $this->actionName = (string) $actionName;
+       protected final function setActionName (string $actionName) {
+               $this->actionName = $actionName;
        }
 
        /**
@@ -75,10 +76,7 @@ abstract class BaseActionResolver extends BaseResolver {
         * @return      $isValid                Whether the given action is valid
         * @throws      InvalidArgumentException        Thrown if given action is not set
         */
-       public function isActionValid ($namespace, $actionName) {
-               // By default nothing shall be valid
-               $isValid = false;
-
+       public function isActionValid (string $namespace, string $actionName) {
                // Is a action set?
                if (empty($namespace)) {
                        // Then thrown an exception here
@@ -93,20 +91,20 @@ abstract class BaseActionResolver extends BaseResolver {
                        '%s\%s%sAction',
                        $namespace,
                        $this->getCapitalizedClassPrefix(),
-                       self::convertToClassName($actionName)
+                       StringUtils::convertToClassName($actionName)
                );
 
                // Now, let us create the full name of the action class
                $this->setClassName($className);
 
                // Is this class already loaded?
-               if (class_exists($this->getClassName())) {
-                       // This class does exist. :-)
-                       $isValid = true;
-               } // END - if
+               $isValid = class_exists($this->getClassName());
 
-               // Set action name
-               $this->setActionName($actionName);
+               // Is it valid?
+               if ($isValid) {
+                       // Set action name
+                       $this->setActionName($actionName);
+               }
 
                // Return the result
                return $isValid;
@@ -126,14 +124,14 @@ abstract class BaseActionResolver extends BaseResolver {
                        '%s\%s%sAction',
                        $this->getNamespace(),
                        $this->getCapitalizedClassPrefix(),
-                       self::convertToClassName($actionName)
+                       StringUtils::convertToClassName($actionName)
                );
 
                // ... and set it
                $this->setClassName($className);
 
                // Initiate the action
-               $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this));
+               $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), [$this]);
 
                // Return the result
                return $actionInstance;