From aafcd2e5f59f75d8f82f03fd0acc7461bc7f448d Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 20 May 2014 20:47:37 +0200 Subject: [PATCH] Had to rename more stuff. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../interfaces/request/class_Requestable.php | 2 +- .../main/class_BaseFrameworkSystem.php | 21 +++++++++++++++++++ inc/classes/main/index/class_BaseIndex.php | 21 +++++++++++-------- inc/classes/main/request/class_ | 2 +- .../request/console/class_ConsoleRequest.php | 2 +- .../main/request/web/class_HttpRequest.php | 2 +- .../main/stacker/file/class_BaseFileStack.php | 19 ++++++++++------- 7 files changed, 48 insertions(+), 21 deletions(-) diff --git a/inc/classes/interfaces/request/class_Requestable.php b/inc/classes/interfaces/request/class_Requestable.php index 754c48bb..2f12a097 100644 --- a/inc/classes/interfaces/request/class_Requestable.php +++ b/inc/classes/interfaces/request/class_Requestable.php @@ -60,7 +60,7 @@ interface Requestable extends FrameworkInterface { * @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) diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 21792097..6c9dad6f 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -2913,6 +2913,27 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $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 * diff --git a/inc/classes/main/index/class_BaseIndex.php b/inc/classes/main/index/class_BaseIndex.php index 66f16db8..aa32af1e 100644 --- a/inc/classes/main/index/class_BaseIndex.php +++ b/inc/classes/main/index/class_BaseIndex.php @@ -71,11 +71,11 @@ class BaseIndex extends BaseFrameworkSystem { $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 @@ -95,23 +95,26 @@ class BaseIndex extends BaseFrameworkSystem { * 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__)); } diff --git a/inc/classes/main/request/class_ b/inc/classes/main/request/class_ index 824771ee..94ec780b 100644 --- a/inc/classes/main/request/class_ +++ b/inc/classes/main/request/class_ @@ -64,7 +64,7 @@ class ???Request extends BaseRequest implements Requestable { * @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."); } diff --git a/inc/classes/main/request/console/class_ConsoleRequest.php b/inc/classes/main/request/console/class_ConsoleRequest.php index 8bebdf24..c0e23b0c 100644 --- a/inc/classes/main/request/console/class_ConsoleRequest.php +++ b/inc/classes/main/request/console/class_ConsoleRequest.php @@ -92,7 +92,7 @@ class ConsoleRequest extends BaseRequest implements Requestable { * @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); } diff --git a/inc/classes/main/request/web/class_HttpRequest.php b/inc/classes/main/request/web/class_HttpRequest.php index 5e5a511d..91527e84 100644 --- a/inc/classes/main/request/web/class_HttpRequest.php +++ b/inc/classes/main/request/web/class_HttpRequest.php @@ -67,7 +67,7 @@ class HttpRequest extends BaseRequest implements Requestable { * @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; diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 4aa880bb..5d198a30 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -108,26 +108,29 @@ class BaseFileStack extends BaseStacker { * 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__)); } -- 2.39.5