X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fhelper%2Fclass_BaseHelper.php;fp=framework%2Fmain%2Fclasses%2Fhelper%2Fclass_BaseHelper.php;h=f32b3618a4cf4e4bd118a7b62676b3164f530e3f;hp=5c6ab7520d910245e58098f4d34cdec48dde0050;hb=9ad41b1a5047ba120036230e61e9d519bcb72a86;hpb=50a5a61a62855fb59a50feb0070205c8cb45dfb8 diff --git a/framework/main/classes/helper/class_BaseHelper.php b/framework/main/classes/helper/class_BaseHelper.php index 5c6ab752..f32b3618 100644 --- a/framework/main/classes/helper/class_BaseHelper.php +++ b/framework/main/classes/helper/class_BaseHelper.php @@ -91,7 +91,11 @@ abstract class BaseHelper extends BaseFrameworkSystem { */ 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!'); } /** @@ -99,9 +103,21 @@ abstract class BaseHelper extends BaseFrameworkSystem { * * @param $newContent New content to add * @return void + * @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))); } /** @@ -109,10 +125,21 @@ abstract class BaseHelper extends BaseFrameworkSystem { * * @param $content Content to to the base * @return void + * @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'] = trim($content); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!'); } /** @@ -120,10 +147,21 @@ abstract class BaseHelper extends BaseFrameworkSystem { * * @param $content Content to to the base * @return void + * @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'] = trim($content); + + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!'); } /**