StringStream
class StringStream extends Stream implements StreamInterface (View source)
The ArrayStream class.
Constants
MODE_READ_ONLY_FROM_BEGIN |
|
MODE_READ_WRITE_FROM_BEGIN |
|
MODE_WRITE_ONLY_RESET |
|
MODE_READ_WRITE_RESET |
|
MODE_WRITE_ONLY_FROM_END |
|
MODE_READ_WRITE_FROM_END |
|
Methods
Class init.
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.
Method to get property Resource
Method to set property seekable
Method to set property writable
Details
at line line 78
__construct(string|resource $stream = '', string $mode = 'rb+')
Class init.
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 line 88
void
close()
Closes the stream and any underlying resources.
at line line 101
Stream
attach(string|resource $stream, string $mode = 'rb+')
Method to attach resource into object.
at line line 132
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 line 150
int|null
getSize()
Get the size of the stream if known.
at line line 166
int
tell()
Returns the current position of the file read/write pointer
at line line 181
bool
eof()
Returns true if the stream is at the end of the stream.
at line line 191
bool
isSeekable()
Returns whether or not the stream is seekable.
at line line 212
boolean
seek(int $offset, int $whence = SEEK_SET)
Seek to a position in the stream.
at line line 251
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 line 263
bool
isWritable()
Returns whether or not the stream is writable.
at line line 276
int
write(string $string)
Write data to the stream.
at line line 295
bool
isReadable()
Returns whether or not the stream is readable.
at line line 311
string
read(int $length)
Read data from the stream.
at line line 330
string
getContents()
Returns the remaining contents in a string
at line line 361
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 streamgetmeta_data() function.
at line line 393
resource
getResource()
Method to get property Resource
at line line 405
StringStream
seekable(boolean $seekable)
Method to set property seekable
at line line 419
StringStream
writable(boolean $writable)
Method to set property writable