* @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,