use Org\Mxchange\CoreFramework\Filesystem\Index\IndexableFile;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Index\Indexable;
+use Org\Mxchange\CoreFramework\Utils\Crypto\CryptoUtils;
// Import SPL stuff
use \BadMethodCallException;
* @param $value Value to be added to the stack
* @return $data Hash and gap position
* @throws InvalidArgumentException If a parameter is not valid
+ * @throws BadMethodCallException If this->indexInstance is not properly set
*/
public function writeValueToFile (string $stackName, $value) {
// Validate parameter
} elseif (is_object($value) || is_resource($value)) {
// Not wanted here
throw new InvalidArgumentException(sprintf('value[]=%s is not stackable in files', gettype($value)));
+ } elseif (!($this->getIndexInstance() instanceof Indexable)) {
+ // Index instance not set
+ throw new BadMethodCallException('this->indexInstance[] is not properly set.');
}
// Encode/convert the value into a "binary format"
// Get a strong hash for the "encoded" data
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: encoded=%s', $encoded));
- $hash = self::hash($encoded);
+ $hash = CryptoUtils::hash($encoded);
// Then write it to the next free gap
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('INDEX-FILE: hash=%s', $hash));