]> git.mxchange.org Git - core.git/commitdiff
Added required method streamData(), maybe someday we will rewrite these classes?
authorRoland Häder <roland@mxchange.org>
Sun, 17 Apr 2011 18:16:13 +0000 (18:16 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 17 Apr 2011 18:16:13 +0000 (18:16 +0000)
inc/classes/main/debug/class_DebugConsoleOutput.php
inc/classes/main/io/class_FileIoStream.php

index a513d63394e81bba1896b7ecbb8ec2c23f55e6af..bf6e0980063726a51221acc283bc0f3d45ce8b0c 100644 (file)
@@ -70,6 +70,18 @@ class DebugConsoleOutput extends BaseFrameworkSystem implements Debugger, Output
                        $this->outputStream($outStream);
                } // END - if
        }
+
+       /**
+        * Streams the data and maybe does something to it
+        *
+        * @param       $data   The data (string mostly) to "stream"
+        * @return      $data   The data (string mostly) to "stream"
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function streamData ($data) {
+               $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
 }
 
 // [EOF]
index 45f1021ec52d35e183c66135a6f1614b71344f7c..fb7096d4648214f7b7bbef924e5c32df5e8fd4d0 100644 (file)
@@ -159,7 +159,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
 
                        // Remember last read line for avoiding possible infinite loops
                        $lastBuffer = $inputBuffer;
-               }
+               } // END - while
 
                // Close directory handle
                $fileInstance->closeFile();
@@ -185,7 +185,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                                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) {
                                // Is a data line!
                                $data = explode($this->seperator, $rawLine);
@@ -199,7 +199,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                                        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);
@@ -211,19 +211,19 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                                // Other raw lines than header/data tagged lines and re-add the new-line char
                                $readData .= $rawLine . "\n";
                        }
-               }
+               } // 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);
@@ -232,13 +232,13 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                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(
@@ -246,6 +246,18 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                        'data'   => $readData
                );
        }
+
+       /**
+        * Streams the data and maybe does something to it
+        *
+        * @param       $data   The data (string mostly) to "stream"
+        * @return      $data   The data (string mostly) to "stream"
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function streamData ($data) {
+               $this->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
 }
 
 // [EOF]