FnStream
in package
implements
StreamInterface
Interfaces, Classes, Traits and Enums
- StreamInterface
- Describes a data stream.
Table of Contents
- $_fn___toString : mixed
- $_fn_close : mixed
- $_fn_detach : mixed
- $_fn_eof : mixed
- $_fn_getContents : mixed
- $_fn_getMetadata : mixed
- $_fn_getSize : mixed
- $_fn_isReadable : mixed
- $_fn_isSeekable : mixed
- $_fn_isWritable : mixed
- $_fn_read : mixed
- $_fn_rewind : mixed
- $_fn_seek : mixed
- $_fn_tell : mixed
- $_fn_write : mixed
- $methods : array<string|int, mixed>
- $slots : array<string|int, mixed>
- __construct() : mixed
- __destruct() : mixed
- __get() : mixed
- __toString() : string
- Reads all data from the stream into a string, from the beginning to end.
- __wakeup() : mixed
- close() : void
- Closes the stream and any underlying resources.
- decorate() : FnStream
- detach() : mixed
- Separates any underlying resources from the stream.
- eof() : bool
- Returns true if the stream is at the end of the stream.
- getContents() : string
- Returns the remaining contents in a string
- getMetadata() : mixed
- Get stream metadata as an associative array or retrieve a specific key.
- getSize() : mixed
- Get the size of the stream if known.
- isReadable() : bool
- Returns whether or not the stream is readable.
- isSeekable() : bool
- Returns whether or not the stream is seekable.
- isWritable() : bool
- Returns whether or not the stream is writable.
- read() : string
- Read data from the stream.
- rewind() : mixed
- Seek to the beginning of the stream.
- seek() : mixed
- Seek to a position in the stream.
- tell() : int
- Returns the current position of the file read/write pointer
- write() : int
- Write data to the stream.
Properties
$_fn___toString
public
mixed
$_fn___toString
$_fn_close
public
mixed
$_fn_close
$_fn_detach
public
mixed
$_fn_detach
$_fn_eof
public
mixed
$_fn_eof
$_fn_getContents
public
mixed
$_fn_getContents
$_fn_getMetadata
public
mixed
$_fn_getMetadata
$_fn_getSize
public
mixed
$_fn_getSize
$_fn_isReadable
public
mixed
$_fn_isReadable
$_fn_isSeekable
public
mixed
$_fn_isSeekable
$_fn_isWritable
public
mixed
$_fn_isWritable
$_fn_read
public
mixed
$_fn_read
$_fn_rewind
public
mixed
$_fn_rewind
$_fn_seek
public
mixed
$_fn_seek
$_fn_tell
public
mixed
$_fn_tell
$_fn_write
public
mixed
$_fn_write
$methods
private
array<string|int, mixed>
$methods
$slots
private
static array<string|int, mixed>
$slots
= ['__toString', 'close', 'detach', 'rewind', 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', 'isReadable', 'read', 'getContents', 'getMetadata']
Methods
__construct()
public
__construct(array<string|int, mixed> $methods) : mixed
Parameters
- $methods : array<string|int, mixed>
Return values
mixed —__destruct()
public
__destruct() : mixed
Return values
mixed —__get()
public
__get(mixed $name) : mixed
Parameters
- $name : mixed
Return values
mixed —__toString()
Reads all data from the stream into a string, from the beginning to end.
public
__toString() : string
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.
Return values
string —__wakeup()
public
__wakeup() : mixed
Return values
mixed —close()
Closes the stream and any underlying resources.
public
close() : void
Return values
void —decorate()
public
static decorate(StreamInterface $stream, array<string|int, mixed> $methods) : FnStream
Parameters
- $stream : StreamInterface
- $methods : array<string|int, mixed>
Return values
FnStream —detach()
Separates any underlying resources from the stream.
public
detach() : mixed
After the stream has been detached, the stream is in an unusable state.
Return values
mixed —Underlying PHP stream, if any
eof()
Returns true if the stream is at the end of the stream.
public
eof() : bool
Return values
bool —getContents()
Returns the remaining contents in a string
public
getContents() : string
Return values
string —getMetadata()
Get stream metadata as an associative array or retrieve a specific key.
public
getMetadata([mixed $key = null ]) : mixed
The keys returned are identical to the keys returned from PHP's stream_get_meta_data() function.
Parameters
- $key : mixed = null
-
Specific metadata to retrieve.
Return values
mixed —Returns an associative array if no key is provided. Returns a specific key value if a key is provided and the value is found, or null if the key is not found.
getSize()
Get the size of the stream if known.
public
getSize() : mixed
Return values
mixed —Returns the size in bytes if known, or null if unknown.
isReadable()
Returns whether or not the stream is readable.
public
isReadable() : bool
Return values
bool —isSeekable()
Returns whether or not the stream is seekable.
public
isSeekable() : bool
Return values
bool —isWritable()
Returns whether or not the stream is writable.
public
isWritable() : bool
Return values
bool —read()
Read data from the stream.
public
read(int $length) : string
Parameters
- $length : int
-
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.
Return values
string —Returns the data read from the stream, or an empty string if no bytes are available.
rewind()
Seek to the beginning of the stream.
public
rewind() : mixed
If the stream is not seekable, this method will raise an exception; otherwise, it will perform a seek(0).
Return values
mixed —seek()
Seek to a position in the stream.
public
seek(int $offset[, int $whence = SEEK_SET ]) : mixed
Parameters
- $offset : int
-
Stream offset
- $whence : int = SEEK_SET
-
Specifies how the cursor position will be calculated based on the seek offset. Valid values are identical to the built-in PHP $whence values for
fseek()
. SEEK_SET: Set position equal to offset bytes SEEK_CUR: Set position to current location plus offset SEEK_END: Set position to end-of-stream plus offset.
Return values
mixed —tell()
Returns the current position of the file read/write pointer
public
tell() : int
Return values
int —Position of the file pointer
write()
Write data to the stream.
public
write(string $string) : int
Parameters
- $string : string
-
The string that is to be written.
Return values
int —Returns the number of bytes written to the stream.