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\Strings\StringUtils;
// Import SPL stuff
use \InvalidArgumentException;
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2019 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @param $className Name of the class
* @return void
*/
- protected function __construct ($className) {
+ protected function __construct (string $className) {
// Call parent constructor
parent::__construct($className);
}
* @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;
}
/**
* @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
'%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;
'%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;