public function read($count)
    {
        $contentLength = strlen($this->data);
        if ($this->position > $contentLength || $count > $contentLength - $this->position) {
            throw new EndOfStreamException(
                sprintf(
                    'End of stream reached when trying to read %d bytes. content length=%d, position=%d',
                    $count,
                    $contentLength,
                    $this->position
                )
            );
        }

        $chunk = substr($this->data, $this->position, $count);
        if ($chunk === false) {
            $chunk = '';
        }

        $readBytes = strlen($chunk);
        $this->position += $readBytes;

        return $chunk;
    }
public function read($count)
    {
        $contentLength = strlen($this->data);
        if ($this->position > $contentLength || $count > $contentLength - $this->position) {
            throw new EndOfStreamException(
                sprintf(
                    'End of stream reached when trying to read %d bytes. content length=%d, position=%d',
                    $count,
                    $contentLength,
                    $this->position
                )
            );
        }

        $chunk = substr($this->data, $this->position, $count);
        if ($chunk === false) {
            $chunk = '';
        }

        $readBytes = strlen($chunk);
        $this->position += $readBytes;

        return $chunk;
    }
public function read ( $ count ) { $ contentLength = strlen ( $ this -> data ) ; if ( $ this -> position > $ contentLength || $ count > $ contentLength - $ this -> position ) { throw new EndOfStreamException ( sprintf ( 'End of stream reached when trying to read %d bytes. content length=%d, position=%d' , $ count , $ contentLength , $ this -> position ) ) ; } $ chunk = substr ( $ this -> data , $ this -> position , $ count ) ; if ( $ chunk === false ) { $ chunk = '' ; } $ readBytes = strlen ( $ chunk ) ; $ this -> position += $ readBytes ; return $ chunk ; }
Returns the desired number of bytes.

@param int $count

@throws EndOfStreamException

@return string
Returns the desired number of bytes .