38 $buffer = $this->buffer;
56 return strlen($this->buffer);
79 public function seek($offset, $whence = SEEK_SET)
81 throw new \RuntimeException(
'Cannot seek a BufferStream');
86 return strlen($this->buffer) === 0;
91 throw new \RuntimeException(
'Cannot determine the position of a BufferStream');
97 public function read($length)
99 $currentLength = strlen($this->buffer);
101 if ($length >= $currentLength) {
103 $result = $this->buffer;
107 $result = substr($this->buffer, 0, $length);
108 $this->buffer = substr($this->buffer, $length);
119 $this->buffer .= $string;
122 if (strlen($this->buffer) >= $this->hwm) {
126 return strlen($string);
135 return $key ? null : [];