// Bail out
ApplicationEntryPoint::exitApplication('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage());
}
- } // END - for
+ }
// Write a header information for validation purposes
$fileInstance->writeToFile(sprintf('%s%s%s%s%s%s%s%s%s' . PHP_EOL,
// Advance to the next 50-chars block
$idx += 50;
- } // END - while
+ }
// Close the file
unset($fileInstance);
// Break infinite loop maybe caused by the input handler
if ($lastBuffer == $inputBuffer) {
break;
- } // END - if
+ }
// Remember last read line for avoiding possible infinite loops
$lastBuffer = $inputBuffer;
- } // END - while
+ }
// Close directory handle
unset($fileInstance);
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) == self::FILE_IO_DATA_BLOCK_ID) {
// Is a data line!
$data = explode(self::FILE_IO_SEPARATOR, $rawLine);
if (md5($data[0]) != $data[1]) {
// MD5 hash did not match!
throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
- } // END - if
+ }
} else {
// Invalid count!
throw new InvalidArrayCountException(array($this, 'data', count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
// Other raw lines than header/data tagged lines and re-add the new-line char
$readData .= $rawLine . PHP_EOL;
}
- } // END - foreach
+ }
// Was raw lines read and no header/data?
if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) {
// Return raw lines back
return $readData;
- } // END - if
+ }
// Was a header found?
if (count($header) != 4) {
// Throw an exception
throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT);
- } // END - if
+ }
// Decode all from Base64
$readData = @base64_decode($readData);
if (strlen($readData) != $header[2]) {
// Size did not match
throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE);
- } // END - if
+ }
// Validate the decoded data with the final MD5 hash
if (md5($readData) != $header[3]) {
// MD5 hash did not match!
throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH);
- } // END - if
+ }
// Return all in an array
return array(