Continued:
[core.git] / framework / main / classes / helper / class_BaseHelper.php
index 625220f718fbca7ec1b19754f9856ff9165f3665..b6545819801dc7d29d5b2cb98b9031e6597d2f38 100644 (file)
@@ -3,18 +3,23 @@
 namespace Org\Mxchange\CoreFramework\Helper;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
+use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
+use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
+
+// Import SPL stuff
+use \BasMethodCallException;
+use \InvalidArgumentException;
 
 /**
  * A generic helper class with generic methods
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 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
  *
@@ -50,12 +55,12 @@ abstract class BaseHelper extends BaseFrameworkSystem {
        /**
         * Array with groups
         */
-       private $groups = array();
+       private $groups = [];
 
        /**
         * Array with sub group
         */
-       private $subGroups = array();
+       private $subGroups = [];
 
        /**
         * Previously opened group
@@ -73,11 +78,10 @@ abstract class BaseHelper extends BaseFrameworkSystem {
        private $totalCounter = 0;
 
        // Exception constants
-       const EXCEPTION_GROUP_NOT_OPENED             = 0x1e3;
-       const EXCEPTION_GROUP_ALREADY_FOUND          = 0x1e4;
-       const EXCEPTION_SUB_GROUP_ALREADY_FOUND      = 0x1e5;
-       const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e6;
-       const EXCEPTION_NO_PREVIOUS_GROUP_OPENED     = 0x1e7;
+       const EXCEPTION_GROUP_NOT_OPENED             = 0x1e0;
+       const EXCEPTION_SUB_GROUP_ALREADY_FOUND      = 0x1e1;
+       const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e2;
+       const EXCEPTION_NO_PREVIOUS_GROUP_OPENED     = 0x1e3;
 
        /**
         * Protected constructor
@@ -85,9 +89,13 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @param       $className      Real name of the class
         * @return      void
         */
-       protected function __construct ($className) {
+       protected function __construct (string $className) {
                // Call parent constructor
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: className=%s - CONSTRUCTED!', $className));
                parent::__construct($className);
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
        }
 
        /**
@@ -95,9 +103,21 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $newContent             New content to add
         * @return      void
-        */
-       protected final function addContent ($newContent) {
-               $this->content .= (string) trim($newContent) . PHP_EOL;
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        */
+       protected final function addContent (string $newContent) {
+               // Check variable
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: newContent=%s - CALLED!', $newContent));
+               if (empty(trim($newContent))) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "newContent" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
+               // Append content with EOL
+               $this->content .= trim($newContent) . PHP_EOL;
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: this->content()=%d - EXIT!', strlen($this->content)));
        }
 
        /**
@@ -105,10 +125,21 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $content        Content to to the base
         * @return      void
-        */
-       protected function addHeaderContent ($content) {
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        */
+       protected function addHeaderContent (string $content) {
+               // Check variable
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: content=%s - CALLED!', $content));
+               if (empty(trim($content))) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                // Add the header content
-               $this->groups['header']['content'] = (string) trim($content);
+               $this->groups['header']['content'] = trim($content);
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
        }
 
        /**
@@ -116,10 +147,21 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $content        Content to to the base
         * @return      void
-        */
-       protected function addFooterContent ($content) {
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        */
+       protected function addFooterContent (string $content) {
+               // Check variable
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: content=%s - CALLED!', $content));
+               if (empty(trim($content))) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                // Add the footer content
-               $this->groups['footer']['content'] = (string) trim($content);
+               $this->groups['footer']['content'] = trim($content);
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
        }
 
        /**
@@ -129,8 +171,16 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $newContent             New content to add
         * @return      void
-        */
-       protected final function addContentToPreviousGroup ($newContent) {
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        */
+       protected final function addContentToPreviousGroup (string $newContent) {
+               // Check on parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: newContent=%s - CALLED!', $newContent));
+               if (empty($newContent)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "newContent" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                // Check for sub/group
                if ($this->ifSubGroupOpenedPreviously()) {
                        // Get sub group id
@@ -148,6 +198,9 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                        // Add it directly
                        $this->addContent($newContent);
                }
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
        }
 
        /**
@@ -174,13 +227,24 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $fieldName      Name of the field to assign
         * @return      void
-        */
-       public function assignField ($fieldName) {
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        */
+       public function assignField (string $fieldName) {
+               // Check on parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s - CALLED!', $fieldName));
+               if (empty($fieldName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                // Get the value from value instance
                $fieldValue = $this->getValueField($fieldName);
 
                // Assign it with a template variable
                $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $fieldValue);
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
        }
 
        /**
@@ -190,18 +254,33 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @param       $fieldName              Name of the field to assign
         * @param       $filterMethod   Method name to call of the value instance
         * @return      void
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
         * @todo        Rewrite this method using a helper class for filtering data
         */
-       public function assignFieldWithFilter ($fieldName, $filterMethod) {
+       public function assignFieldWithFilter (string $fieldName, string $filterMethod) {
+               // Validate parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s,filterMethod=%s - CALLED!', $fieldName, $filterMethod));
+               if (empty($fieldName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               } elseif (empty($filterMethod)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "filterMethod" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                // Get the value
                $fieldValue = $this->getValueField($fieldName);
-               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'='.$fieldValue);
 
                // Now filter it through the value through the filter method
-               $filteredValue = call_user_func_array(array($this, 'doFilter' . self::convertToClassName($filterMethod)), array($fieldValue));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: %s[%s]=%s', $fieldName, gettype($fieldValue), $fieldValue));
+               $filteredValue = call_user_func_array(array($this, 'doFilter' . StringUtils::convertToClassName($filterMethod)), array($fieldValue));
 
                // Assign it with a template variable
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: filteredValue[%s]=%s', gettype($filteredValue), $filteredValue));
                $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $filteredValue);
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
        }
 
        /**
@@ -210,36 +289,47 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @param       $registryKey    Registry key which holds an object with values
         * @param       $extraKey               Extra value instance key used if registryKey is null
         * @return      void
-        * @throws      NullPointerException    If recovery of requested value instance failed
-        */
-       public function prefetchValueInstance ($registryKey, $extraKey = NULL) {
-               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('O:'.$registryKey.'/'.$extraKey);
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        */
+       public function prefetchValueInstance (string $registryKey, string $extraKey = NULL) {
+               // Validate parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: registryKey=%s,extraKey[%s]=%s - CALLED!', $registryKey, gettype($extraKey), $extraKey));
+               if (empty($registryKey)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "registryKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                try {
                        // Get the required instance
-                       $this->valueInstance = GenericRegistry::getRegistry()->getInstance($registryKey);
+                       $this->valueInstance = ObjectRegistry::getRegistry('generic')->getInstance($registryKey);
                } catch (NullPointerException $e) {
                        // Not set in registry
-                       // @TODO Try to log it here
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($registryKey.'=NULL!');
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: registryKey=%s returned no instance (NPE thrown)', $registryKey));
                }
 
                // Shall we get an extra instance?
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey[%s]=%s', gettype($extraKey), $extraKey));
                if (!is_null($extraKey)) {
                        try {
                                // Get the extra instance.
-                               $this->extraInstance = GenericRegistry::getRegistry()->getInstance($extraKey);
+                               $this->extraInstance = ObjectRegistry::getRegistry('generic')->getInstance($extraKey);
                        } catch (NullPointerException $e) {
                                // Try to create it
-                               $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance));
+                               //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey=%s returned no instance (NPE thrown), this->valueInstance[]=%s', $extraKey, gettype($this->valueInstance)));
+                               $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', [$this->valueInstance]);
                        }
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!');
-               } // END - if
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey=%s,this->extraInstance[%s]=%s', $extraKey, gettype($this->extraInstance), $this->extraInstance));
+               }
 
                // Is the value instance valid?
+               //* NOSIY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->valueInstance[]=%s - BEFORE!', gettype($this->valueInstance)));
                if (is_null($this->valueInstance)) {
                        // Get the requested instance
                        $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance));
-               } // END - if
+               }
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->valueInstance[]=%s - AFTER/EXIT!', gettype($this->valueInstance)));
        }
 
        /**
@@ -251,20 +341,31 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @param       $content        Initial content to add to the group
         * @param       $tag            HTML tag used to open this group
         * @return      void
-        * @throws      HelperGroupAlreadyCreatedException      If the group was already created before
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        * @throws      BadMethodCallException  If the group was already created before
         */
-       protected function openGroupByIdContent ($groupId, $content, $tag) {
-               //* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
+       protected function openGroupByIdContent (string $groupId, string $content, string $tag) {
                // Is the group already there?
-               if (isset($this->groups[$groupId])) {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: groupdId=%s,content=%s,tag=%s - CALLED!', $groupdId, $content, $tag));
+               if (empty($groupId)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               } elseif (isset($this->groups[$groupId])) {
                        // Then throw an exception here
-                       throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND);
-               } // END - if
+                       throw new BadMethodCallException(sprintf('[%s:%d]: groupId=%s is already opened.', $this->__toString(), $groupId), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
+               } elseif (empty($content)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               } elseif (empty($tag)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "tag" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
 
                // Count one up
                $this->totalCounter++;
 
                // Add the group to the stack
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->totalCounter=%d', $this->totalCounter));
                $this->groups[$this->totalCounter] = $groupId;
                $this->groups[$groupId]['opened']  = true;
                $this->groups[$groupId]['content'] = sprintf(
@@ -277,7 +378,11 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                $this->groups[$groupId]['tag'] = $tag;
 
                // Mark this group as previously opened
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: Setting this->previousGroupId=%s ...', $groupId));
                $this->setPreviousGroupId($groupId);
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
        }
 
        /**
@@ -288,18 +393,19 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @return      void
         * @throws      HelperNoPreviousOpenedGroupException    If no previously opened group was found
         */
-       public function closePreviousGroupByContent ($content = '') {
+       public function closePreviousGroupByContent (string $content = '') {
                // Check if any sub group was opened before
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: content(%d)=%s - CALLED!', strlen($content), $content));
                if ($this->ifSubGroupOpenedPreviously()) {
                        // Close it automatically
                        $this->closePreviousSubGroupByContent();
-               } // END - if
+               }
 
                // Check if any group was opened before
                if ($this->ifGroupOpenedPreviously() === false) {
                        // Then throw an exception
                        throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
-               } // END - if
+               }
 
                // Get previous group
                $groupId = $this->getPreviousGroupId();
@@ -312,7 +418,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                                $groupId,
                                $this->groups[$groupId]['tag']
                        );
-               } // END - if
+               }
 
                // Add content to it and mark it as closed
                $this->groups[$groupId]['content'] .= sprintf(
@@ -326,7 +432,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
 
                // Mark previous group as closed
                $this->setPreviousGroupId('');
-               //* DEBUG: */ echo "CLOSE:groupId={$groupId}<br />\n";
+               //* NOISY-DEBUG: */ echo "CLOSE:groupId={$groupId}<br />\n";
        }
 
        /**
@@ -340,13 +446,16 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @return      void
         * @throws      HelperSubGroupAlreadyCreatedException   If the sub group was already created before
         */
-       protected function openSubGroupByIdContent ($subGroupId, $content, $tag) {
-               //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
+       protected function openSubGroupByIdContent (string $subGroupId, string $content, string $tag) {
+               //* NOISY-DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
                // Is the group already there?
-               if (isset($this->subGroups[$subGroupId])) {
+               if (empty($subGroupId)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "subGroupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               } elseif (isset($this->subGroups[$subGroupId])) {
                        // Then throw an exception here
                        throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND);
-               } // END - if
+               }
 
                // Count one up
                $this->totalCounter++;
@@ -369,12 +478,12 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @return      void
         * @throws      HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
         */
-       public function closePreviousSubGroupByContent ($content = '') {
+       public function closePreviousSubGroupByContent (string $content = '') {
                // Check if any sub group was opened before
                if ($this->ifSubGroupOpenedPreviously() === false) {
                        // Then throw an exception
                        throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
-               } // END - if
+               }
 
                // Get previous sub group
                $subGroupId = $this->getPreviousSubGroupId();
@@ -383,7 +492,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) {
                        // Get it from opener
                        $content = sprintf('<!-- sub-group %s auto-closed //--></%s>', $subGroupId, $this->subGroups[$subGroupId]['tag']);
-               } // END - if
+               }
 
                // Add content to it and mark it as closed
                $this->subGroups[$subGroupId]['content'] .= sprintf('<!-- sub-group %s closed (length: %s, tag: %s) //-->%s' . PHP_EOL, $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content);
@@ -392,7 +501,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
 
                // Mark previous sub group as closed
                $this->setPreviousSubGroupId('');
-               //* DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}<br />\n";
+               //* NOISY-DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}<br />\n";
        }
 
        /**
@@ -408,7 +517,7 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                if (isset($this->groups['header'])) {
                        // Then add it
                        $content .= $this->groups['header']['content'] . PHP_EOL;
-               } // END - if
+               }
 
                // Initiate content
                $content .= $this->getContent();
@@ -419,27 +528,27 @@ abstract class BaseHelper extends BaseFrameworkSystem {
                        if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) {
                                // Then add it's content
                                $groupContent = trim($this->groups[$this->groups[$idx]]['content']);
-                               //* DEBUG: */ echo "group={$this->groups[$idx]},content=<pre>".htmlentities($groupContent)."</pre><br />\n";
+                               //* NOISY-DEBUG: */ echo "group={$this->groups[$idx]},content=<pre>".htmlentities($groupContent)."</pre><br />\n";
                                $content .= $groupContent;
                        } elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === false)) {
                                // Then add it's content
                                $subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content'];
-                               //* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
+                               //* NOISY-DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
                                $content .= trim($subGroupContent);
                        } else {
                                // Something went wrong
                                $this->debugInstance(__METHOD__ . '(): Something unexpected happened here.');
                        }
-               } // END - for
+               }
 
                // Is footer content there?
                if (isset($this->groups['footer'])) {
                        // Then add it
                        $content .= $this->groups['footer']['content'] . PHP_EOL;
-               } // END - if
+               }
 
                // Return it
-               //* DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
+               //* NOISY-DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
                return $content;
        }
 
@@ -448,12 +557,21 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $groupId        Id of group to check
         * @return      $isOpened       Whether the specified group is open
-        */
-       protected function ifGroupIsOpened ($groupId) {
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
+        */
+       protected function ifGroupIsOpened (string $groupId) {
+               // Check on parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: groupId=%s - CALLED!', $groupId));
+               if (empty($groupId)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "groupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                // Is the group open?
                $isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === true));
 
                // Return status
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: isOpened=%d - EXIT!', intval($isOpened)));
                return $isOpened;
        }
 
@@ -462,33 +580,42 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         *
         * @param       $fieldName              Name of the field we shall fetch
         * @return      $fieldValue             Value from field
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
         * @throws      NullPointerException    Thrown if $valueInstance is null
         */
-       public function getValueField ($fieldName) {
+       public function getValueField (string $fieldName) {
+               // Check parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s - CALLED!', $fieldName));
+               if (empty($fieldName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
+               }
+
                // Init value
                $fieldValue = NULL;
 
                // The $valueInstance attribute should not be null!
                if (is_null($this->getValueInstance())) {
                        // Throws an exception here
-                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
+                       throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
+               }
 
                // Is the field set?
                if ($this->getValueInstance()->isFieldSet($fieldName)) {
                        // Get the field value
                        $fieldValue = $this->getValueInstance()->getField($fieldName);
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!');
                } elseif ((!is_null($this->extraInstance)) && ($this->extraInstance->isFieldSet($fieldName))) {
                        // So try the extra instance
                        $fieldValue = $this->extraInstance->getField($fieldName);
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!');
                } else {
                        // Field is not set
-                       $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fieldName=' . $fieldName . ' is not set! - @TODO');
-               } // END - if
+                       $this->debugOutput('BASE-HELPER: fieldName=' . $fieldName . ' is not set! - @TODO');
+               }
 
                // Return it
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldValue[%s]=%s - EXIT!', gettype($fieldValue), $fieldValue));
                return $fieldValue;
        }
 
@@ -536,8 +663,8 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @param       $previousGroupId        Id of previously opened group
         * @return      void
         */
-       protected final function setPreviousGroupId ($previousGroupId) {
-               $this->previousGroupId = (string) $previousGroupId;
+       protected final function setPreviousGroupId (string $previousGroupId) {
+               $this->previousGroupId = $previousGroupId;
        }
 
        /**
@@ -555,8 +682,8 @@ abstract class BaseHelper extends BaseFrameworkSystem {
         * @param       $previousSubGroupId             Id of previously opened sub group
         * @return      void
         */
-       protected final function setPreviousSubGroupId ($previousSubGroupId) {
-               $this->previousSubGroupId = (string) $previousSubGroupId;
+       protected final function setPreviousSubGroupId (string $previousSubGroupId) {
+               $this->previousSubGroupId = $previousSubGroupId;
        }
 
 }