StreamInterface
interface StreamInterface (View source)
Describes a data stream.
Typically, an instance will wrap a PHP stream; this interface provides a wrapper around the most common operations, including serialization of the entire stream to a string.
Methods
Reads all data from the stream into a string, from the beginning to end.
Closes the stream and any underlying resources.
Separates any underlying resources from the stream.
Get the size of the stream if known.
Returns the current position of the file read/write pointer
Returns true if the stream is at the end of the stream.
Returns whether or not the stream is seekable.
Seek to a position in the stream.
Seek to the beginning of the stream.
Returns whether or not the stream is writable.
Write data to the stream.
Returns whether or not the stream is readable.
Read data from the stream.
Returns the remaining contents in a string
Get stream metadata as an associative array or retrieve a specific key.
Details
at line 28
string
__toString()
Reads all data from the stream into a string, from the beginning to end.
This method MUST attempt to seek to the beginning of the stream before reading data and read the stream until the end is reached.
Warning: This could attempt to load a large amount of data into memory.
This method MUST NOT raise an exception in order to conform with PHP's string casting operations.
at line 35
void
close()
Closes the stream and any underlying resources.
at line 44
resource|null
detach()
Separates any underlying resources from the stream.
After the stream has been detached, the stream is in an unusable state.
at line 51
int|null
getSize()
Get the size of the stream if known.
at line 59
int
tell()
Returns the current position of the file read/write pointer
at line 66
bool
eof()
Returns true if the stream is at the end of the stream.
at line 73
bool
isSeekable()
Returns whether or not the stream is seekable.
at line 87
seek(int $offset, int $whence = SEEK_SET)
Seek to a position in the stream.
at line 99
rewind()
Seek to the beginning of the stream.
If the stream is not seekable, this method will raise an exception; otherwise, it will perform a seek(0).
at line 106
bool
isWritable()
Returns whether or not the stream is writable.
at line 115
int
write(string $string)
Write data to the stream.
at line 122
bool
isReadable()
Returns whether or not the stream is readable.
at line 134
string
read(int $length)
Read data from the stream.
at line 143
string
getContents()
Returns the remaining contents in a string
at line 157
array|mixed|null
getMetadata(string $key = null)
Get stream metadata as an associative array or retrieve a specific key.
The keys returned are identical to the keys returned from PHP's stream_get_meta_data() function.