Stream
class Stream implements StreamInterface, Stringable
Properties
| protected int | $size | ||
| protected bool | $detached |
Methods
Create a new stream instance.
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 21
__construct(string $contents = '')
Create a new stream instance.
at line 36
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 48
void
close()
Closes the stream and any underlying resources.
at line 59
null|resource
detach()
Separates any underlying resources from the stream.
After the stream has been detached, the stream is in an unusable state.
at line 73
int|null
getSize()
Get the size of the stream if known.
at line 84
int
tell()
Returns the current position of the file read/write pointer.
at line 92
bool
eof()
Returns true if the stream is at the end of the stream.
at line 104
bool
isSeekable()
Returns whether or not the stream is seekable.
at line 121
void
seek(int $offset, int $whence = SEEK_SET)
Seek to a position in the stream.
at line 135
void
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 143
bool
isWritable()
Returns whether or not the stream is writable.
at line 155
int
write(string $string)
Write data to the stream.
at line 172
bool
isReadable()
Returns whether or not the stream is readable.
at line 187
string
read(int $length)
Read data from the stream.
at line 220
string
getContents()
Returns the remaining contents in a string.
at line 239
mixed
getMetadata(string|null $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.