public function read($byteCount, $allowIncomplete = false)
    {
        $maxByteCount = $this->getRemainingByteCount();
        if (!$allowIncomplete && $maxByteCount < $byteCount) {
            throw new Exception\UnderflowException('The source doesn\'t have enough remaining data to fulfill the request');
        }

        $byteCount = max(min($byteCount, $maxByteCount), 0);
        $substr = substr($this->data, $this->offset, $byteCount);
        $this->moveCursor($substr);

        return $substr;
    }
public function read($byteCount, $allowIncomplete = false)
    {
        $maxByteCount = $this->getRemainingByteCount();
        if (!$allowIncomplete && $maxByteCount < $byteCount) {
            throw new Exception\UnderflowException('The source doesn\'t have enough remaining data to fulfill the request');
        }

        $byteCount = max(min($byteCount, $maxByteCount), 0);
        $substr = substr($this->data, $this->offset, $byteCount);
        $this->moveCursor($substr);

        return $substr;
    }
public function read ( $ byteCount , $ allowIncomplete = false ) { $ maxByteCount = $ this -> getRemainingByteCount ( ) ; if ( ! $ allowIncomplete && $ maxByteCount < $ byteCount ) { throw new Exception \ UnderflowException ( 'The source doesn\'t have enough remaining data to fulfill the request' ) ; } $ byteCount = max ( min ( $ byteCount , $ maxByteCount ) , 0 ) ; $ substr = substr ( $ this -> data , $ this -> offset , $ byteCount ) ; $ this -> moveCursor ( $ substr ) ; return $ substr ; }
Reads and consumes data from the source.

@param int  $byteCount       Number of bytes to read
@param bool $allowIncomplete true to accept any amount of data smaller than or equal to the requested amount, false (default) to throw an exception if the exact requested amount cannot be read

@throws Exception\UnderflowException If the exact requested amount cannot be read

@return string The data that was just read
Reads and consumes data from the source .