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) {
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 : [];
eof()
Returns true if the stream is at the end of the stream.
seek($offset, $whence=SEEK_SET)
Seek to a position in the stream.
close()
Closes the stream and any underlying resources.
Provides a buffer stream that can be written to to fill a buffer, and read from to remove bytes from ...
getSize()
Get the size of the stream if known.
rewind()
Seek to the beginning of the stream.
tell()
Returns the current position of the file read/write pointer.
write($string)
Writes data to the buffer.
read($length)
Reads data from the buffer.
isWritable()
Returns whether or not the stream is writable.
isReadable()
Returns whether or not the stream is readable.
detach()
Separates any underlying resources from the stream.
isSeekable()
Returns whether or not the stream is seekable.
getContents()
Returns the remaining contents in a string.
__toString()
Reads all data from the stream into a string, from the beginning to end.
getMetadata($key=null)
Get stream metadata as an associative array or retrieve a specific key.