Documentation

ArrayByteStream
in package
implements InputInterface, OutputInterface

Array byte stream class

Tags
category

Pop

author

Chris Corbyn, from the SwiftMailer library https://github.com/swiftmailer/swiftmailer

version
3.6.0

Interfaces, Classes and Traits

InputInterface
Input byte stream interface
OutputInterface
Output byte stream interface

Table of Contents

$array  : array<string|int, mixed>
The internal stack of bytes
$arraySize  : int
The size of the stack
$mirrors  : array<string|int, mixed>
Bound streams
$offset  : int
The internal pointer offset
__construct()  : mixed
Create a new ArrayByteStream.
bind()  : mixed
Attach $is to this stream.
commit()  : mixed
Not used
flushBuffers()  : mixed
Flush the contents of the stream (empty it) and set the internal pointer to the beginning.
read()  : string
Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
setReadPointer()  : bool
Move the internal read pointer to $byteOffset in the stream.
unbind()  : mixed
Remove an already bound stream.
write()  : int|void
Writes $bytes to the end of the stream

Properties

$array

The internal stack of bytes

private array<string|int, mixed> $array = []

$mirrors

Bound streams

private array<string|int, mixed> $mirrors = []

Methods

__construct()

Create a new ArrayByteStream.

public __construct([mixed $stack = null ]) : mixed

If $stack is given the stream will be populated with the bytes it contains.

Parameters
$stack : mixed = null

of bytes in string or array form, optional

Return values
mixed

bind()

Attach $is to this stream.

public bind(InputInterface $is) : mixed

The stream acts as an observer, receiving all data that is written. All and operations will be mirrored.

Parameters
$is : InputInterface
Return values
mixed

flushBuffers()

Flush the contents of the stream (empty it) and set the internal pointer to the beginning.

public flushBuffers() : mixed
Return values
mixed

read()

Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.

public read(int $length) : string

If less bytes exist than are requested the remaining bytes are given instead. If no bytes are remaining at all, boolean false is returned.

Parameters
$length : int
Return values
string

setReadPointer()

Move the internal read pointer to $byteOffset in the stream.

public setReadPointer(int $byteOffset) : bool
Parameters
$byteOffset : int
Return values
bool

unbind()

Remove an already bound stream.

public unbind(InputInterface $is) : mixed

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
Return values
mixed

write()

Writes $bytes to the end of the stream

public write(string $bytes) : int|void
Parameters
$bytes : string
Return values
int|void

Search results