Buffer
extends AbstractFilterableInputStream
in package
implements
BufferInterface
Stream buffer class
Tags
Table of Contents
Interfaces
- BufferInterface
- SMTP buffer interface
Properties
- $sequence : int
- Write sequence
- $filters : array<string|int, mixed>
- StreamFilters
- $in : mixed
- The input stream
- $mirrors : array<string|int, mixed>
- Bound streams
- $out : mixed
- The output stream
- $params : array<string|int, mixed>
- Buffer initialization parameters $var array
- $replacementFactory : ReplacementFactoryInterface
- The ReplacementFilterFactory
- $stream : mixed
- A primary socket
- $translations : array<string|int, mixed>
- Translations performed on data being streamed into the buffer
- $writeBuffer : string
- A buffer for writing
Methods
- __construct() : mixed
- Create a new StreamBuffer using $replacementFactory for transformations.
- 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.
- initialize() : void
- Perform any initialization needed, using the given $params.
- read() : string|bool
- Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
- readLine() : string
- Get a line of output (including any CRLF).
- removeFilter() : void
- Remove an already present StreamFilter based on its $key
- setParam() : void
- Set an individual param on the buffer (e.g. switching to SSL)
- setReadPointer() : void
- Not implemented
- setWriteTranslations() : void
- Set an array of string replacements which should be made on data written to the buffer.
- startTls() : bool
- Start TLS
- terminate() : void
- Perform any shutdown logic needed
- unbind() : void
- Remove an already bound stream.
- write() : mixed
- Writes $bytes to the end of the stream
- commitBytes() : int
- Write bytes to the stream
- flush() : void
- Flush the stream contents
- doWrite() : void
- Just write the bytes to the stream
- establishProcessConnection() : void
- Opens a process for input/output
- establishSocketConnection() : void
- Establishes a connection to a remote server
- filter() : mixed
- Run $bytes through all filters
- getReadConnectionDescription() : string
- Get read connection description
Properties
$sequence
Write sequence
protected
int
$sequence
= 0
$filters
StreamFilters
private
array<string|int, mixed>
$filters
= []
$in
The input stream
private
mixed
$in
$mirrors
Bound streams
private
array<string|int, mixed>
$mirrors
= []
$out
The output stream
private
mixed
$out
$params
Buffer initialization parameters $var array
private
array<string|int, mixed>
$params
= []
$replacementFactory
The ReplacementFilterFactory
private
ReplacementFactoryInterface
$replacementFactory
$stream
A primary socket
private
mixed
$stream
$translations
Translations performed on data being streamed into the buffer
private
array<string|int, mixed>
$translations
= []
$writeBuffer
A buffer for writing
private
string
$writeBuffer
= ''
Methods
__construct()
Create a new StreamBuffer using $replacementFactory for transformations.
public
__construct(ReplacementFactoryInterface $replacementFactory) : mixed
Parameters
- $replacementFactory : ReplacementFactoryInterface
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
initialize()
Perform any initialization needed, using the given $params.
public
initialize(array<string|int, mixed> $params) : void
Parameters will vary depending upon the type of IoBuffer used.
Parameters
- $params : array<string|int, mixed>
read()
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|boolreadLine()
Get a line of output (including any CRLF).
public
readLine(int|string $sequence) : string
The $sequence number comes from any writes and may or may not be used depending upon the implementation.
Parameters
- $sequence : int|string
-
of last write to scan from
Tags
Return values
stringremoveFilter()
Remove an already present StreamFilter based on its $key
public
removeFilter(string $key) : void
Parameters
- $key : string
setParam()
Set an individual param on the buffer (e.g. switching to SSL)
public
setParam(string $param, mixed $value) : void
Parameters
- $param : string
- $value : mixed
setReadPointer()
Not implemented
public
setReadPointer(int|string $byteOffset) : void
Parameters
- $byteOffset : int|string
setWriteTranslations()
Set an array of string replacements which should be made on data written to the buffer.
public
setWriteTranslations(array<string|int, mixed> $replacements) : void
This could replace LF with CRLF for example.
Parameters
- $replacements : array<string|int, mixed>
startTls()
Start TLS
public
startTls() : bool
Return values
boolterminate()
Perform any shutdown logic needed
public
terminate() : void
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()
Write bytes to the stream
protected
commitBytes(string $bytes) : int
Parameters
- $bytes : string
Return values
intflush()
Flush the stream contents
protected
flush() : void
doWrite()
Just write the bytes to the stream
private
doWrite(int|string $bytes) : void
Parameters
- $bytes : int|string
establishProcessConnection()
Opens a process for input/output
private
establishProcessConnection() : void
establishSocketConnection()
Establishes a connection to a remote server
private
establishSocketConnection() : void
filter()
Run $bytes through all filters
private
filter(int|string $bytes) : mixed
Parameters
- $bytes : int|string
getReadConnectionDescription()
Get read connection description
private
getReadConnectionDescription() : string