]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/stacker/file/class_BaseFileStack.php
Continued:
[core.git] / framework / main / classes / stacker / file / class_BaseFileStack.php
index 6718eac25e97926c7df484b9a95dd372c9a362af..ef8a7c8a0ed3dd43872d22e6c39f02ce21068de9 100644 (file)
@@ -705,10 +705,23 @@ abstract class BaseFileStack extends BaseStacker {
         * @param       $hash           Hash from encoded value
         * @param       $encoded        Encoded value to be written to the file
         * @return      $data           Gap position and length of the raw data
+        * @throws      InvalidArgumentException        If a parameter has an invalid value
         */
        public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
-               // Raw data been written to the file
+               // Check parameter
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash{}=0x%s,encoded()=%d - CALLED!', $stackName, bin2hex($hash), strlen($encoded)));
+               if (empty($stackName)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "stackName" is empty');
+               } elseif (empty($hash)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "hash" is empty');
+               } elseif (empty($encoded)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "encoded" is empty');
+               }
+
+               // Raw data been written to the file
                $rawData = sprintf('%s%s%s%s%s',
                        $stackName,
                        BinaryFile::SEPARATOR_GROUP_HASH,