Refacuring:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 01:42:04 +0000 (02:42 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 01:42:04 +0000 (02:42 +0100)
- moved state, template and resolver instances to distinct traits

Signed-off-by: Roland Häder <roland@mxchange.org>
25 files changed:
framework/main/classes/actions/class_BaseAction.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/commands/class_BaseCommand.php
framework/main/classes/controller/class_BaseController.php
framework/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php
framework/main/classes/helper/html/class_BaseHtmlHelper.php
framework/main/classes/helper/html/forms/class_HtmlFormHelper.php
framework/main/classes/helper/html/links/class_HtmlLinkHelper.php
framework/main/classes/images/class_BaseImage.php
framework/main/classes/mailer/class_BaseMailer.php
framework/main/classes/menu/class_BaseMenu.php
framework/main/classes/parser/class_BaseParser.php
framework/main/classes/resolver/action/class_BaseActionResolver.php
framework/main/classes/resolver/command/class_BaseCommandResolver.php
framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php
framework/main/classes/resolver/command/html/class_HtmlCommandResolver.php
framework/main/classes/resolver/command/image/class_ImageCommandResolver.php
framework/main/classes/template/image/class_ImageTemplateEngine.php
framework/main/classes/template/mail/class_MailTemplateEngine.php
framework/main/classes/template/menu/class_MenuTemplateEngine.php
framework/main/interfaces/resolver/actions/class_ActionResolver.php
framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php
framework/main/traits/resolver/class_ResolverTrait.php [new file with mode: 0644]
framework/main/traits/state/class_StateableTrait.php [new file with mode: 0644]
framework/main/traits/template/class_CompileableTemplateTrait.php [new file with mode: 0644]

index 40813e418aa78e94cea8667a15496f2f9fc2843d..6507cc2f5f0f9043200699627935a6c1caa9f21a 100644 (file)
@@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Action;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Resolver\Resolver;
+use Org\Mxchange\CoreFramework\Traits\Resolver\ResolverTrait;
 
 /**
  * A general action class. You shall extend this class if you are going to write
@@ -31,10 +31,8 @@ use Org\Mxchange\CoreFramework\Resolver\Resolver;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseAction extends BaseFrameworkSystem {
-       /**
-        * Resolver instance
-        */
-       private $resolverInstance = NULL;
+       // Load traits
+       use ResolverTrait;
 
        /**
         * Protected constructor
@@ -47,23 +45,4 @@ abstract class BaseAction extends BaseFrameworkSystem {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for resolver instance
-        *
-        * @param       $resolverInstance       Instance of a command resolver class
-        * @return      void
-        */
-       protected final function setResolverInstance (Resolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
-       /**
-        * Getter for resolver instance
-        *
-        * @return      $resolverInstance       Instance of a command resolver class
-        */
-       protected final function getResolverInstance () {
-               return $this->resolverInstance;
-       }
-
 }
index e64f1241f9492d4954a7206cab6610d3e37444a1..67a85fd1a87a15d14cf00cc81017318a76e07bf5 100644 (file)
@@ -65,11 +65,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         */
        private $realClass = __CLASS__;
 
-       /**
-        * State instance
-        */
-       private $stateInstance = NULL;
-
        /**
         * Call-back instance
         */
@@ -431,16 +426,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                return $webOutputInstance;
        }
 
-       /**
-        * Setter for state instance
-        *
-        * @param       $stateInstance  A Stateable instance
-        * @return      void
-        */
-       public final function setStateInstance (Stateable $stateInstance) {
-               $this->stateInstance = $stateInstance;
-       }
-
        /**
         * Getter for state instance
         *
@@ -1777,6 +1762,7 @@ Loaded includes:
         * "Getter" for a printable state name
         *
         * @return      $stateName      Name of the node's state in a printable format
+        * @todo        Move this class away from this monolithic place (not whole class is monolithic)
         */
        public final function getPrintableState () {
                // Default is 'null'
index 6d6a9ebc77110d502d68c9e4d141bfde7282aabf..b66cb3ff45412546b66891ae50512a464fd2b4af 100644 (file)
@@ -8,9 +8,10 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Resolver;
 use Org\Mxchange\CoreFramework\Response\Responseable;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Resolver\ResolverTrait;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
+
 /**
  * A general (base) command
  *
@@ -34,15 +35,9 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseCommand extends BaseFrameworkSystem {
-       /**
-        * Resolver instance
-        */
-       private $resolverInstance = NULL;
-
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
+       // Load traits
+       use CompileableTemplateTrait;
+       use ResolverTrait;
 
        /**
         * Protected constructor
@@ -55,44 +50,6 @@ abstract class BaseCommand extends BaseFrameworkSystem {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for resolver instance
-        *
-        * @param       $resolverInstance       Instance of a command resolver class
-        * @return      void
-        */
-       protected final function setResolverInstance (Resolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
-       /**
-        * Getter for resolver instance
-        *
-        * @return      $resolverInstance       Instance of a command resolver class
-        */
-       protected final function getResolverInstance () {
-               return $this->resolverInstance;
-       }
-
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
        /**
         * Initializes the template engine
         *
index dc5fe7045a13e3cae5ef180923a85449e54cc8ec..56c0e214a4929041230a07e7c70ffc069b84d11e 100644 (file)
@@ -10,8 +10,8 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Request\Requestable;
-use Org\Mxchange\CoreFramework\Resolver\Resolver;
 use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Traits\Resolver\ResolverTrait;
 
 /**
  * A generic controller class. You should extend this base class if you want to
@@ -38,6 +38,9 @@ use Org\Mxchange\CoreFramework\Response\Responseable;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseController extends BaseFrameworkSystem implements Registerable {
+       // Load traits
+       use ResolverTrait;
+
        // Exception constants
        const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10;
 
@@ -45,11 +48,6 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl
        const FILTER_CHAIN_PRE_COMMAND  = 'controller_pre_command';
        const FILTER_CHAIN_POST_COMMAND = 'controller_post_command';
 
-       /**
-        * Resolver instance
-        */
-       private $resolverInstance = NULL;
-
        /**
         * Generic filter chains
         */
@@ -73,25 +71,6 @@ abstract class BaseController extends BaseFrameworkSystem implements Registerabl
                GenericRegistry::getRegistry()->addInstance('controller', $this);
        }
 
-       /**
-        * Setter for resolver instance
-        *
-        * @param       $resolverInstance       Instance of a command resolver class
-        * @return      void
-        */
-       protected final function setResolverInstance (Resolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
-       }
-
-       /**
-        * Getter for resolver instance
-        *
-        * @return      $resolverInstance       Instance of a command resolver class
-        */
-       protected final function getResolverInstance () {
-               return $this->resolverInstance;
-       }
-
        /**
         * Executes a command with pre and post filters
         *
index 8ad5440e864cec26c6537c4aff9536551af1e93b..b4c51bf976fc753627773e569e0661b03589cd53 100644 (file)
@@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Template\Xml;
 use Org\Mxchange\CoreFramework\Generic\BaseDecorator;
 use Org\Mxchange\CoreFramework\Response\Responseable;
 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A decorator for XML template engines which rewrites the XML for compacting
@@ -31,10 +32,8 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableTemplate {
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
+       // Load traits
+       use CompileableTemplateTrait;
 
        /**
         * Protected constructor
@@ -63,25 +62,6 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT
                return $templateInstance;
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       protected final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
        /**
         * Settter for variable group
         *
index f2928b9b65c7a2ed5cc10a9f0e37e61a0225ba75..c1f05f768d7d682be5a44ab5392195fc15186772 100644 (file)
@@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Helper;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Helper\BaseHelper;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general purpose web helper. You should not instance this like all the other
@@ -30,11 +30,8 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseHtmlHelper extends BaseHelper {
-
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
+       // Load traits
+       use CompileableTemplateTrait;
 
        /**
         * Protected constructor
@@ -47,23 +44,4 @@ abstract class BaseHtmlHelper extends BaseHelper {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
 }
index 87884e45167f5c0524d3b0d5c68a664150d801da..54422a82dde079691acbc040f10f843158bf0f87 100644 (file)
@@ -83,7 +83,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate {
         * @param       $withForm                       Whether include the form tag
         * @return      $helperInstance         A preparedf instance of this helper
         */
-       public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false, $withForm = true) {
+       public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, string $formName, $formId = false, bool $withForm = true) {
                // Get new instance
                $helperInstance = new HtmlFormHelper();
 
index dcef00c9499257be5e446793e916aac632396186..b97e0810389320ea544902c967edd66db60ba4d1 100644 (file)
@@ -73,7 +73,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate {
         * @return      $helperInstance         A prepared instance of this helper
         * @throws      NoConfigEntryException  A deprecated exception at this point
         */
-       public static final function createHtmlLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = NULL) {
+       public static final function createHtmlLinkHelper (CompileableTemplate $templateInstance, string $linkName, $linkBase = NULL) {
                // Get new instance
                $helperInstance = new HtmlLinkHelper();
 
index df66bc4d3de8f64a7a57ade9d04c9b73ccb62758..5ba5ce437815f3415473e4138a6276e02adaaa83 100644 (file)
@@ -5,7 +5,7 @@ namespace Org\Mxchange\CoreFramework\Image;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general image class
@@ -30,6 +30,9 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
+       // Load traits
+       use CompileableTemplateTrait;
+
        /**
         * Image type
         */
@@ -38,23 +41,23 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
        /**
         * Width of the image
         */
-       private $width = '';
+       private $width = 0;
 
        /**
         * Height of the image
         */
-       private $height = '';
+       private $height = 0;
 
        /**
         * X/Y
         */
-       private $x = '';
-       private $y = '';
+       private $x = 0;
+       private $y = 0;
 
        /**
         * Font size
         */
-       private $fontSize = '';
+       private $fontSize = 0;
 
        /**
         * Image string
@@ -104,11 +107,6 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
         */
        private $groupable = 'single';
 
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -453,25 +451,6 @@ abstract class BaseImage extends BaseFrameworkSystem implements Registerable {
                $this->stringName = $stringName;
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
        /**
         * Finish this image by producing it
         *
index 70c6bcd93a1f97dde6ae062f16a073c273fdaf72..43d92ec075a842095e9aa4eb7772c6aa6b33c316 100644 (file)
@@ -7,7 +7,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general mailer class for all other mailers
@@ -32,16 +32,14 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseMailer extends BaseFrameworkSystem {
+       // Load traits
+       use CompileableTemplateTrait;
+
        /**
         * Template name
         */
        private $templateName = '';
 
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -203,23 +201,4 @@ abstract class BaseMailer extends BaseFrameworkSystem {
                return $this->getGenericArray('recipients');
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
 }
index 03879712a18bae144e15ff85aa493b692ca677e1..2defb635302b403f97425e41a294767bdb17010b 100644 (file)
@@ -8,7 +8,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general menu system class
@@ -33,11 +33,8 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseMenu extends BaseFrameworkSystem {
-
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
+       // Load traits
+       use CompileableTemplateTrait;
 
        /**
         * Protected constructor
@@ -50,25 +47,6 @@ abstract class BaseMenu extends BaseFrameworkSystem {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
        /**
         * Renders the menu by loading the base template and a menu-specific
         * template.
index 92070b8bf36ea328c70df2d60dcede69319e2d67..7435458a2a6bd9c9d2c6529fe93d982f94dc9548 100644 (file)
@@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Parser;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general Parser
@@ -29,10 +29,8 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseParser extends BaseFrameworkSystem {
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
+       // Load traits
+       use CompileableTemplateTrait;
 
        /**
         * Protected constructor
@@ -45,23 +43,4 @@ abstract class BaseParser extends BaseFrameworkSystem {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       public final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
 }
index 9834165250df87fecb5d51af4f567dcda744238e..6a30c35c2a509534525ee9ffbbc367719d2adfb6 100644 (file)
@@ -76,7 +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) {
+       public function isActionValid (string $namespace, string $actionName) {
                // Is a action set?
                if (empty($namespace)) {
                        // Then thrown an exception here
index 53a24d617f3e6efaf59d6fb3a16025345d69f1af..9d5177aa4575fe5eb5c4b5e3bc1c55c52d86f84b 100644 (file)
@@ -207,7 +207,7 @@ abstract class BaseCommandResolver extends BaseResolver {
         * @return      $isValid                Whether the given command is valid
         * @throws      InvalidArgumentException        Thrown if given command is not set
         */
-       protected function isCommandValid ($namespace, $commandName) {
+       protected function isCommandValid (string $namespace, string $commandName) {
                // Is namespace and command name set?
                if (empty($namespace)) {
                        // Then thrown an exception here
index 7cd5109e78096b1e1d9b3bb5685b647005e4ff05..9d3af9fdb269663336b1bbd4ded54f5c356bf8d5 100644 (file)
@@ -55,7 +55,7 @@ class ConsoleCommandResolver extends BaseCommandResolver implements CommandResol
         * @throws      InvalidArgumentException        Thrown if default command is not set
         * @throws      InvalidCommandException         Thrown if default command is invalid
         */
-       public static final function createConsoleCommandResolver ($namespace, $commandName) {
+       public static final function createConsoleCommandResolver (string $namespace, string $commandName) {
                // Create the new instance
                $resolverInstance = new ConsoleCommandResolver();
 
index d28e3d83b97418a702d89a85b1422ca65d9a026a..294b68cb13f1a1b397d0eaafb0e055736e263592 100644 (file)
@@ -58,7 +58,7 @@ class HtmlCommandResolver extends BaseCommandResolver implements CommandResolver
         * @throws      InvalidArgumentException        Thrown if default command is not set
         * @throws      InvalidCommandException         Thrown if default command is invalid
         */
-       public static final function createHtmlCommandResolver ($commandName) {
+       public static final function createHtmlCommandResolver (string $commandName) {
                // Create the new instance
                $resolverInstance = new HtmlCommandResolver();
 
@@ -68,6 +68,7 @@ class HtmlCommandResolver extends BaseCommandResolver implements CommandResolver
                        throw new InvalidArgumentException('Parameter "commandName" is empty');
                } elseif ($resolverInstance->isCommandValid($commandName) === false) {
                        // Invalid command found
+                       // @TODO Missing namespace!
                        throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
 
index b120dc107ccd254173403198951c40520630e373..8baf41e6c87ad90c75df1970d241d0912cf1b361 100644 (file)
@@ -58,7 +58,7 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve
         * @throws      InvalidArgumentException                Thrown if default command is not set
         * @throws      InvalidCommandException         Thrown if default command is invalid
         */
-       public static final function createImageCommandResolver ($commandName) {
+       public static final function createImageCommandResolver (string $commandName) {
                // Create the new instance
                $resolverInstance = new ImageCommandResolver();
 
@@ -67,6 +67,7 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve
                        // Then thrown an exception here
                        throw new InvalidArgumentException('Parameter "commandName" is empty');
                } elseif ($resolverInstance->isCommandValid($commandName) === false) {
+                       // @TODO Missing namespace!
                        // Invalid command found
                        throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
                }
index d01ec650e400b105b3eb6925f07949a575d3f103..6eeedefaf5d116fd2c0d934456af7edd2a60b579 100644 (file)
@@ -197,7 +197,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public function startElement ($resource, $element, array $attributes) {
+       public function startElement ($resource, string $element, array $attributes) {
                // Initial method name which will never be called...
                $methodName = 'initImage';
 
@@ -230,10 +230,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public function finishElement ($resource, $nodeName) {
-               // Make all lower-case
-               $nodeName = strtolower($nodeName);
-
+       public function finishElement ($resource, string $nodeName) {
                // Does this match with current main node?
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
index 24261f747c8badfb8f63a3220d040b1dcc91dc52..7406248eabd35166aabc0d318d88d9c9a80f3da8 100644 (file)
@@ -43,19 +43,19 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
        /**
         * Main nodes in the XML tree
         */
-       private $mainNodes = array(
+       private $mainNodes = [
                'mail-data'
-       );
+       ];
 
        /**
         * Sub nodes in the XML tree
         */
-       private $subNodes = array(
+       private $subNodes = [
                'subject-line',
                'sender-address',
                'recipient-address',
                'message'
-       );
+       ];
 
        /**
         * Mailer instance
@@ -168,7 +168,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public function startElement ($resource, $element, array $attributes) {
+       public function startElement ($resource, string $element, array $attributes) {
                // Initial method name which will never be called...
                $methodName = 'initEmail';
 
@@ -201,10 +201,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public function finishElement ($resource, $nodeName) {
-               // Make all lower-case
-               $nodeName = strtolower($nodeName);
-
+       public function finishElement ($resource, string $nodeName) {
                // Does this match with current main node?
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
index 777412745014f0538be020d2209812c03b37bbf9..5df5e14f1eb8d33b1bbaa01a9908e0f5f0f97b5e 100644 (file)
@@ -9,8 +9,9 @@ use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
 use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
 use Org\Mxchange\CoreFramework\Parser\Parseable;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
 use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
+use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 // Import SPL stuff
@@ -128,11 +129,6 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         */
        private $menuInstance = NULL;
 
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -223,25 +219,6 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                return $this->menuInstance;
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a CompileableTemplate class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a CompileableTemplate class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
        /**
         * Load a specified menu template into the engine
         *
@@ -249,7 +226,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         *                                              located in 'menu' by default
         * @return      void
         */
-       public function loadMenuTemplate ($template) {
+       public function loadMenuTemplate (string $template) {
                // Set template type
                $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('menu_template_type'));
 
@@ -272,8 +249,8 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @param       $element                Element name to set as current main node
         * @return      $currMainNode   Current main node
         */
-       private final function setCurrMainNode ($element) {
-               $this->curr['main_node'] = (string) $element;
+       private final function setCurrMainNode (string $element) {
+               $this->curr['main_node'] = $element;
        }
 
        /**
@@ -303,7 +280,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
         */
-       public function startElement ($resource, $element, array $attributes) {
+       public function startElement ($resource, string $element, array $attributes) {
                // Initial method name which will never be called...
                $methodName = 'initMenu';
 
@@ -339,10 +316,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         * @return      void
         * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
         */
-       public function finishElement ($resource, $nodeName) {
-               // Make all lower-case
-               $nodeName = strtolower($nodeName);
-
+       public function finishElement ($resource, string $nodeName) {
                // Does this match with current main node?
                //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
                if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
index 79823bbe5640f2b04b102e08fc9c2ae6f122a2d8..0ef09a6249357ba7ecd91becd7f1b7da3e3e6a84 100644 (file)
@@ -52,6 +52,6 @@ interface ActionResolver extends Resolver {
         * @return      $isValid                Whether the given action is valid
         * @throws      InvalidArgumentException        Thrown if namespace or action is not set
         */
-       function isActionValid ($namespace, $actionName);
+       function isActionValid (string $namespace, string $actionName);
 
 }
index 7c9aac58c48d92dfbb6f108b77da75fba1439070..631f1f1cb075025d7bb4623ff8a8a1b929410d75 100644 (file)
@@ -54,7 +54,7 @@ class TestsConsoleCommandResolver extends BaseCommandResolver implements Command
         * @throws      InvalidArgumentException                Thrown if default command is not set
         * @throws      InvalidCommandException         Thrown if default command is invalid
         */
-       public static final function createTestsConsoleCommandResolver ($commandName) {
+       public static final function createTestsConsoleCommandResolver (string $commandName) {
                // Create the new instance
                $resolverInstance = new TestsConsoleCommandResolver();
 
diff --git a/framework/main/traits/resolver/class_ResolverTrait.php b/framework/main/traits/resolver/class_ResolverTrait.php
new file mode 100644 (file)
index 0000000..c3f0b1b
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Resolver;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Resolver\Resolver;
+
+/**
+ * A trait for resolver
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait ResolverTrait {
+       /**
+        * Resolver instance
+        */
+       private $resolverInstance = NULL;
+
+       /**
+        * Setter for resolver instance
+        *
+        * @param       $resolverInstance       Instance of a command resolver class
+        * @return      void
+        */
+       protected final function setResolverInstance (Resolver $resolverInstance) {
+               $this->resolverInstance = $resolverInstance;
+       }
+
+       /**
+        * Getter for resolver instance
+        *
+        * @return      $resolverInstance       Instance of a command resolver class
+        */
+       protected final function getResolverInstance () {
+               return $this->resolverInstance;
+       }
+
+}
diff --git a/framework/main/traits/state/class_StateableTrait.php b/framework/main/traits/state/class_StateableTrait.php
new file mode 100644 (file)
index 0000000..128c096
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\State;
+
+use Org\Mxchange\CoreFramework\State\Stateable;
+
+/**
+ * A trait for states
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait StateableTrait {
+       /**
+        * State instance
+        */
+       private $stateInstance = NULL;
+
+       /**
+        * Setter for state instance
+        *
+        * @param       $stateInstance  A Stateable instance
+        * @return      void
+        */
+       public final function setStateInstance (Stateable $stateInstance) {
+               $this->stateInstance = $stateInstance;
+       }
+
+       /**
+        * Getter for state instance
+        *
+        * @return      $stateInstance  A Stateable instance
+        */
+       public final function getStateInstance () {
+               return $this->stateInstance;
+       }
+
+}
diff --git a/framework/main/traits/template/class_CompileableTemplateTrait.php b/framework/main/traits/template/class_CompileableTemplateTrait.php
new file mode 100644 (file)
index 0000000..f762b25
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Template;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+
+/**
+ * A trait for compileable templates
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait CompileableTemplateTrait {
+       /**
+        * Template engine instance
+        */
+       private $templateInstance = NULL;
+
+       /**
+        * Setter for template engine instances
+        *
+        * @param       $templateInstance       An instance of a CompileableTemplate class
+        * @return      void
+        */
+       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
+               $this->templateInstance = $templateInstance;
+       }
+
+       /**
+        * Getter for template engine instances
+        *
+        * @return      $templateInstance       An instance of a CompileableTemplate class
+        */
+       public final function getTemplateInstance () {
+               return $this->templateInstance;
+       }
+
+}