]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/streams/raw_data/input/class_RawDataInputStream.php
Used exit() instead of die()
[hub.git] / application / hub / main / streams / raw_data / input / class_RawDataInputStream.php
index 38deb7aa40cf6e0e30e2d931625f32a79db421c9..d7cb9d8f3fa9843bd527aa35741e9fe276dae478 100644 (file)
@@ -35,10 +35,9 @@ class RawDataInputStream extends BaseStream implements InputStreamable {
        /**
         * Creates an instance of this node class
         *
-        * @param       $handlerInstance        An instance of a Networkable class
         * @return      $streamInstance         An instance of this node class
         */
-       public final static function createRawDataInputStream (Networkable $handlerInstance) {
+       public final static function createRawDataInputStream () {
                // Get a new instance
                $streamInstance = new RawDataInputStream();
 
@@ -58,19 +57,19 @@ class RawDataInputStream extends BaseStream implements InputStreamable {
         */
        public function streamData ($data) {
                // Do we have start and end marker again?
-               assert((substr($data, 0, 5) == '[[S]]') && (substr($data, -5, 5) == '[[E]]'));
+               assert($this->ifStartEndMarkerSet($data));
 
                // Remove both
-               $data = substr($data, 6 - 5);
+               $data = substr($data, strlen(BaseRawDataHandler::STREAM_START_MARKER), -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER));
 
                // Can it be validated?
                if ((strlen($data) % 4) != 0) {
                        // Length modulo 4 must be zero, else it is an invalid Base64 message
-                       $this->getHandlerInstance()->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MODULO);
+                       $handlerInstance->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MODULO);
                        $data = false;
                } elseif (!$this->isBase64Encoded($data)) {
                        // Is not a valid Base64-encoded message
-                       $this->getHandlerInstance()->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MESSAGE);
+                       $handlerInstance->setErrorCode(BaseRawDataHandler::SOCKET_ERROR_INVALID_BASE64_MESSAGE);
                        $data = false;
                } else {
                        // Decode the data with BASE64-encoding