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
4.0.0

Table of Contents

Interfaces

InputInterface
Input byte stream interface
OutputInterface
Output byte stream interface

Properties

$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

Methods

__construct()  : mixed
Create a new ArrayByteStream.
bind()  : void
Attach $is to this stream.
commit()  : void
Not used
flushBuffers()  : void
Flush the contents of the stream (empty it) and set the internal pointer to the beginning.
read()  : string|bool
Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
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

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

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

flushBuffers()

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

public flushBuffers() : void

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
Return values
string|bool

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

        
On this page

Search results