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.
Return 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 22
__construct(string $contents = '')
Create a new stream instance.
at line 37
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 49
void
close()
Closes the stream and any underlying resources.
at line 60
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 74
int|null
getSize()
Get the size of the stream if known.
at line 84
int
tell()
Return the current position of the file read/write pointer.
at line 93
bool
eof()
Returns true if the stream is at the end of the stream.
at line 105
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 132
void
rewind()
Seek to the beginning of the stream.
at line 141
bool
isWritable()
Returns whether or not the stream is writable.
at line 153
int
write(string $string)
Write data to the stream.
at line 170
bool
isReadable()
Returns whether or not the stream is readable.
at line 185
string
read(int $length)
Read data from the stream.
at line 218
string
getContents()
Returns the remaining contents in a string.
at line 237
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.