![]() |
TYPO3
7.6
|
Public Member Functions | |
__construct ($stream, $mode= 'r') | |
__toString () | |
close () | |
detach () | |
getSize () | |
tell () | |
eof () | |
isSeekable () | |
seek ($offset, $whence=SEEK_SET) | |
rewind () | |
isWritable () | |
write ($string) | |
isReadable () | |
read ($length) | |
getContents () | |
getMetadata ($key=null) | |
attach ($resource, $mode= 'r') | |
Protected Attributes | |
$resource | |
$stream | |
Default implementation for the StreamInterface of the PSR-7 standard Acts mainly as a decorator class for streams/resources.
Highly inspired by https://github.com/phly/http/
Definition at line 27 of file Stream.php.
__construct | ( | $stream, | |
$mode = 'r' |
|||
) |
Constructor setting up the PHP resource
string | resource | $stream | |
string | $mode | Mode with which to open stream |
\InvalidArgumentException |
Definition at line 47 of file Stream.php.
References Stream\$stream, and elseif.
__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.
Implements StreamInterface.
Definition at line 73 of file Stream.php.
References Stream\getContents(), Stream\isReadable(), and Stream\rewind().
attach | ( | $resource, | |
$mode = 'r' |
|||
) |
Attach a new stream/resource to the instance.
string | resource | $resource | |
string | $mode |
\InvalidArgumentException | for stream identifier that cannot be cast to a resource |
\InvalidArgumentException | for non-resource stream |
Definition at line 341 of file Stream.php.
References Stream\$resource.
close | ( | ) |
Closes the stream and any underlying resources.
Implements StreamInterface.
Definition at line 91 of file Stream.php.
References Stream\$resource, and Stream\detach().
detach | ( | ) |
Separates any underlying resources from the stream.
After the stream has been detached, the stream is in an unusable state.
Implements StreamInterface.
Definition at line 107 of file Stream.php.
References Stream\$resource.
Referenced by Stream\close().
eof | ( | ) |
Returns true if the stream is at the end of the stream.
Implements StreamInterface.
Definition at line 151 of file Stream.php.
getContents | ( | ) |
Returns the remaining contents in a string
\RuntimeException | if unable to read or an error occurs while reading. |
Implements StreamInterface.
Definition at line 295 of file Stream.php.
References Stream\isReadable().
Referenced by Stream\__toString().
getMetadata | ( | $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.
Implements StreamInterface.
Definition at line 321 of file Stream.php.
Referenced by Stream\isReadable(), Stream\isSeekable(), and Stream\isWritable().
getSize | ( | ) |
Get the size of the stream if known.
Implements StreamInterface.
Definition at line 119 of file Stream.php.
isReadable | ( | ) |
Returns whether or not the stream is readable.
Implements StreamInterface.
Definition at line 254 of file Stream.php.
References Stream\getMetadata().
Referenced by Stream\__toString(), Stream\getContents(), and Stream\read().
isSeekable | ( | ) |
Returns whether or not the stream is seekable.
Implements StreamInterface.
Definition at line 164 of file Stream.php.
References Stream\getMetadata().
Referenced by Stream\seek().
isWritable | ( | ) |
Returns whether or not the stream is writable.
Implements StreamInterface.
Definition at line 221 of file Stream.php.
References Stream\getMetadata().
read | ( | $length | ) |
Read data from the stream.
int | $length | Read up to $length bytes from the object and return them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes. |
\RuntimeException | if an error occurs. |
Implements StreamInterface.
Definition at line 273 of file Stream.php.
References Stream\isReadable().
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).
Implements StreamInterface.
Definition at line 211 of file Stream.php.
References Stream\seek().
Referenced by Stream\__toString().
seek | ( | $offset, | |
$whence = SEEK_SET |
|||
) |
Seek to a position in the stream.
Implements StreamInterface.
Definition at line 186 of file Stream.php.
References Stream\isSeekable().
Referenced by Stream\rewind().
tell | ( | ) |
Returns the current position of the file read/write pointer
\RuntimeException | on error. |
Implements StreamInterface.
Definition at line 134 of file Stream.php.
write | ( | $string | ) |
Write data to the stream.
string | $string | The string that is to be written. |
\RuntimeException | on failure. |
Implements StreamInterface.
Definition at line 237 of file Stream.php.
|
protected |
Definition at line 33 of file Stream.php.
Referenced by Stream\attach(), Stream\close(), and Stream\detach().
|
protected |
Definition at line 38 of file Stream.php.
Referenced by Stream\__construct().