TemporaryFileByteStream
extends FileByteStream
in package
Temporary file byte stream class
Tags
Table of Contents
Properties
- $sequence : int
- Write sequence
- $filters : array<string|int, mixed>
- StreamFilters
- $mirrors : array<string|int, mixed>
- Bound streams
- $mode : string
- The mode this file is opened in for writing
- $offset : int
- The internal pointer offset
- $path : string
- The path to the file
- $reader : mixed
- A lazy-loaded resource handle for reading the file
- $seekable : mixed
- If stream is seekable true/false, or null if not known
- $writeBuffer : string
- A buffer for writing
- $writer : mixed
- A lazy-loaded resource handle for writing the file
Methods
- __construct() : mixed
- Create a new TemporaryFileByteStream
- __destruct() : mixed
- Destructor
- addFilter() : void
- Add a StreamFilter to this InputByteStream
- bind() : void
- Attach $is to this stream.
- commit() : void
- For any bytes that are currently buffered inside the stream, force them off the buffer
- flushBuffers() : void
- Flush the contents of the stream (empty it) and set the internal pointer to the beginning.
- getContent() : string
- Get content
- getPath() : string
- Get the complete path to the file
- read() : string|bool
- Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
- removeFilter() : void
- Remove an already present StreamFilter based on its $key
- setReadPointer() : void
- Move the internal read pointer to $byteOffset in the stream
- unbind() : void
- Remove an already bound stream.
- write() : mixed
- Writes $bytes to the end of the stream
- commitBytes() : int
- Commit the given bytes to the storage medium immediately
- flush() : void
- Flush any buffers/content with immediate effect
- copyReadStream() : void
- Copy a readOnly Stream to ensure seekability
- doWrite() : void
- Just write the bytes to the stream
- filter() : mixed
- Run $bytes through all filters
- getReadHandle() : mixed
- Get the resource for reading
- getReadStreamSeekableStatus() : void
- Check if ReadOnly Stream is seekable
- getWriteHandle() : mixed
- Get the resource for writing
- resetReadHandle() : void
- Force a reload of the resource for reading
- seekReadStreamToPosition() : void
- Streams in a readOnly stream ensuring copy if needed
Properties
$sequence
Write sequence
protected
int
$sequence
= 0
$filters
StreamFilters
private
array<string|int, mixed>
$filters
= []
$mirrors
Bound streams
private
array<string|int, mixed>
$mirrors
= []
$mode
The mode this file is opened in for writing
private
string
$mode
$offset
The internal pointer offset
private
int
$offset
= 0
$path
The path to the file
private
string
$path
$reader
A lazy-loaded resource handle for reading the file
private
mixed
$reader
$seekable
If stream is seekable true/false, or null if not known
private
mixed
$seekable
= null
$writeBuffer
A buffer for writing
private
string
$writeBuffer
= ''
$writer
A lazy-loaded resource handle for writing the file
private
mixed
$writer
Methods
__construct()
Create a new TemporaryFileByteStream
public
__construct() : mixed
Tags
__destruct()
Destructor
public
__destruct() : mixed
addFilter()
Add a StreamFilter to this InputByteStream
public
addFilter(FilterInterface $filter, string $key) : void
Parameters
- $filter : FilterInterface
- $key : string
bind()
Attach $is to this stream.
public
bind(InputInterface $is) : void
The stream acts as an observer, receiving all data that is written. All and operations will be mirrored.
Parameters
- $is : InputInterface
commit()
For any bytes that are currently buffered inside the stream, force them off the buffer
public
commit() : void
flushBuffers()
Flush the contents of the stream (empty it) and set the internal pointer to the beginning.
public
flushBuffers() : void
getContent()
Get content
public
getContent() : string
Tags
Return values
stringgetPath()
Get the complete path to the file
public
getPath() : string
Return values
stringread()
Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
public
read(int|string $length) : string|bool
If less bytes exist than are requested the remaining bytes are given instead. If no bytes are remaining at all, bool false is returned.
Parameters
- $length : int|string
Tags
Return values
string|boolremoveFilter()
Remove an already present StreamFilter based on its $key
public
removeFilter(string $key) : void
Parameters
- $key : string
setReadPointer()
Move the internal read pointer to $byteOffset in the stream
public
setReadPointer(int|string $byteOffset) : void
Parameters
- $byteOffset : int|string
unbind()
Remove an already bound stream.
public
unbind(InputInterface $is) : void
If $is is not bound, no errors will be raised. If the stream currently has any buffered data it will be written to $is before unbinding occurs.
Parameters
- $is : InputInterface
write()
Writes $bytes to the end of the stream
public
write(string $bytes) : mixed
Parameters
- $bytes : string
commitBytes()
Commit the given bytes to the storage medium immediately
protected
abstract commitBytes(string $bytes) : int
Parameters
- $bytes : string
Return values
intflush()
Flush any buffers/content with immediate effect
protected
abstract flush() : void
copyReadStream()
Copy a readOnly Stream to ensure seekability
private
copyReadStream() : void
doWrite()
Just write the bytes to the stream
private
doWrite(int|string $bytes) : void
Parameters
- $bytes : int|string
filter()
Run $bytes through all filters
private
filter(int|string $bytes) : mixed
Parameters
- $bytes : int|string
getReadHandle()
Get the resource for reading
private
getReadHandle() : mixed
Tags
getReadStreamSeekableStatus()
Check if ReadOnly Stream is seekable
private
getReadStreamSeekableStatus() : void
getWriteHandle()
Get the resource for writing
private
getWriteHandle() : mixed
Tags
resetReadHandle()
Force a reload of the resource for reading
private
resetReadHandle() : void
seekReadStreamToPosition()
Streams in a readOnly stream ensuring copy if needed
private
seekReadStreamToPosition(int|string $offset) : void
Parameters
- $offset : int|string