Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 14 Apr 2018 21:21:30 +0000 (23:21 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 14 Apr 2018 21:21:30 +0000 (23:21 +0200)
- assignVariable() should validate $variableName if NULL or empty

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/template/class_BaseTemplateEngine.php

index 67a4bae..adcfda2 100644 (file)
@@ -7,6 +7,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
+use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
@@ -1114,17 +1115,21 @@ abstract class BaseTemplateEngine extends BaseFrameworkSystem {
         * @param       $variableName   The variable we are looking for
         * @param       $value                  The value we want to store in the variable
         * @return      void
+        * @throws      NullPointerException    If $variableName is NULL
         * @throws      InvalidArgumentException        If the variable name is left empty
         */
        public final function assignVariable ($variableName, $value) {
-               // Replace all dashes to underscores to match variables with configuration entries
-               $variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
-
-               // Empty variable found?
-               if (empty($variableName)) {
+               // Validate parameter
+               if (is_null($variableName)) {
+                       // Throw NPE
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } elseif (empty($variableName)) {
                        // Throw an exception
                        throw new InvalidArgumentException('Parameter "variableName" is empty');
-               } // END - if
+               }
+
+               // Replace all dashes to underscores to match variables with configuration entries
+               $variableName = trim(StringUtils::convertDashesToUnderscores($variableName));
 
                // First search for the variable if it was already added
                $index = $this->getVariableIndex($variableName);