+ /**
+ * Adds the chunk to the final array which will be used for the final step
+ * which will be to assemble all chunks back to the original package content
+ * and for the final hash check.
+ *
+ * This method may throw an exception if a chunk with the same serial number
+ * has already been added to avoid mixing chunks from different packages.
+ *
+ * @param $chunkSplits An array from a splitted chunk
+ * @return void
+ */
+ private function addChunkToFinalArray (array $chunkSplits) {
+ // Is the serial number (index 1) already been added?
+ if (isset($this->finalPackageChunks[$chunkSplits[1])) {
+ // Then throw an exception
+ throw new ChunkAlreadyAssembledException(array($this, $chunkSplits), self::EXCEPTION_CHUNK_ALREADY_ASSEMBLED);
+ } // END - if
+
+ // Add the chunk data (index 2) to the final array and use the serial number as index
+ $this->finalPackageChunks['content'][$chunkSplits[1]] = $chunkSplits[2];
+
+ // ... and the hash as well
+ $this->finalPackageChunks['hashes'][$chunkSplits[1]] = $chunkSplits[0];
+ }
+