/**
* File header indicator
*/
- private $fileHeader = '@head';
+ const FILE_IO_FILE_HEADER_ID = '@head';
/**
* Data block indicator
*/
- private $dataBlock = '@data';
+ const FILE_IO_DATA_BLOCK_ID = '@data';
/**
* Seperator #1
*/
- private $chunker = ':';
+ const FILE_IO_CHUNKER = ':';
/**
* Seperator #2
*/
- private $seperator = '^';
+ const FILE_IO_SEPERATOR = '^';
/**
* Protected constructor
// Write a header information for validation purposes
$fileInstance->writeToFile(sprintf("%s%s%s%s%s%s%s%s%s\n",
- $this->fileHeader,
- $this->seperator,
+ self::FILE_IO_FILE_HEADER_ID,
+ self::FILE_IO_SEPERATOR,
$dataArray[0],
- $this->chunker,
+ self::FILE_IO_CHUNKER,
time(),
- $this->chunker,
+ self::FILE_IO_CHUNKER,
strlen($dataArray[1]),
- $this->chunker,
+ self::FILE_IO_CHUNKER,
md5($dataArray[1])
));
// Save it to the stream
$fileInstance->writeToFile(sprintf("%s%s%s%s%s\n",
- $this->dataBlock,
- $this->seperator,
+ self::FILE_IO_DATA_BLOCK_ID,
+ self::FILE_IO_SEPERATOR,
$line,
- $this->chunker,
+ self::FILE_IO_CHUNKER,
md5($line)
));
$rawLine = rtrim($rawLine);
// Analyze this line
- if (substr($rawLine, 0, 5) == $this->fileHeader) {
+ if (substr($rawLine, 0, 5) == self::FILE_IO_FILE_HEADER_ID) {
// Header found, so let's extract it
- $header = explode($this->seperator, $rawLine);
+ $header = explode(self::FILE_IO_SEPERATOR, $rawLine);
$header = trim($header[1]);
// Now we must convert it again into an array
- $header = explode($this->chunker, $header);
+ $header = explode(self::FILE_IO_CHUNKER, $header);
// Is the header (maybe) valid?
if (count($header) != 4) {
// Throw an exception
throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
} // END - if
- } elseif (substr($rawLine, 0, 5) == $this->dataBlock) {
+ } elseif (substr($rawLine, 0, 5) == self::FILE_IO_DATA_BLOCK_ID) {
// Is a data line!
- $data = explode($this->seperator, $rawLine);
+ $data = explode(self::FILE_IO_SEPERATOR, $rawLine);
$data = $data[1];
// First element is the data, second the MD5 checksum
- $data = explode($this->chunker, $data);
+ $data = explode(self::FILE_IO_CHUNKER, $data);
// Validate the read line
if (count($data) == 2) {