* @param $headerName Name of the header
* @return $headerValue Value of the header or 'null' if not found
*/
- function getHeader ($headerName);
+ function getHeaderElement ($headerName);
/**
* Sets whether the request was valid (default: TRUE)
$this->headerSize = $headerSize;
}
+ /**
+ * Getter for header array
+ *
+ * @return $totalEntries Size of file header
+ */
+ protected final function getHeade () {
+ // Get it
+ return $this->header;
+ }
+
+ /**
+ * Setter for header
+ *
+ * @param $header Array for a file header
+ * @return void
+ */
+ protected final function setHeader (array $header) {
+ // Set it
+ $this->header = $header;
+ }
+
/**
* Getter for seek position
*
$this->getIteratorInstance()->rewind();
// Then read it (see constructor for calculation)
- $data = $this->getIteratorInstance()->read($this->headerSize);
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->headerSize));
+ $data = $this->getIteratorInstance()->read($this->getHeaderSize());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getHeaderSize()));
// Have all requested bytes been read?
- assert(strlen($data) == $this->headerSize);
+ assert(strlen($data) == $this->getHeaderSize());
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Last character must be the separator
* 0 => magic
* 1 => total entries
*/
- $this->header = explode(chr(self::SEPARATOR_HEADER_DATA), $data);
+ $header = explode(chr(self::SEPARATOR_HEADER_DATA), $data);
+
+ // Set it here
+ $this->setHeader($header);
// Check if the array has only 3 elements
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($this->header), print_r($this->header, TRUE)));
- assert(count($this->header) == 2);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, TRUE)));
+ assert(count($header) == 2);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Check magic
- assert($this->header[0] == self::INDEX_MAGIC);
+ assert($header[0] == self::INDEX_MAGIC);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Check length of count
- assert(strlen($this->header[1]) == self::LENGTH_COUNT);
+ assert(strlen($header[1]) == self::LENGTH_COUNT);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Decode count
- $this->header[1] = hex2bin($this->header[1]);
+ $header[1] = hex2bin($header[1]);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
}
* @param $headerName Name of the header
* @return $headerValue Value of the header or 'null' if not found
*/
- public function getHeader ($headerName) {
+ public function getHeaderElement ($headerName) {
$this->partialStub("Please implement this method.");
}
* @return $headerValue Value of the header or 'null' if not found
* @throws UnsupportedOperationException This method should never be called
*/
- public function getHeader ($headerName) {
+ public function getHeaderElement ($headerName) {
// Console doesn't have any headers
throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @param $headerName Name of the header
* @return $headerValue Value of the header or 'null' if not found
*/
- public function getHeader ($headerName) {
+ public function getHeaderElement ($headerName) {
// Default return value on error
$headerValue = NULL;
* 1 => total entries
* 2 => current seek position
*/
- $this->header = explode(chr(self::SEPARATOR_HEADER_DATA), $data);
+ $header = explode(chr(self::SEPARATOR_HEADER_DATA), $data);
+
+ // Set header here
+ $this->setHeader($header);
// Check if the array has only 3 elements
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($this->header), print_r($this->header, TRUE)));
- assert(count($this->header) == 3);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, TRUE)));
+ assert(count($header) == 3);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Check magic
- assert($this->header[0] == self::STACK_MAGIC);
+ assert($header[0] == self::STACK_MAGIC);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Check length of count and seek position
- assert(strlen($this->header[1]) == self::LENGTH_COUNT);
+ assert(strlen($header[1]) == self::LENGTH_COUNT);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
- assert(strlen($this->header[2]) == self::LENGTH_POSITION);
+ assert(strlen($header[2]) == self::LENGTH_POSITION);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Decode count and seek position
- $this->header[1] = hex2bin($this->header[1]);
- $this->header[2] = hex2bin($this->header[2]);
+ $header[1] = hex2bin($header[1]);
+ $header[2] = hex2bin($header[2]);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
}