\Pop\Mail\Transport\Smtp\Stream\ByteArrayByteStream

Array byte stream class

Summary

Methods
Properties
Constants
__construct()
read()
write()
commit()
bind()
unbind()
setReadPointer()
flushBuffers()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$array
$arraySize
$offset
$mirrors
N/A

Properties

$array

$array : array

The internal stack of bytes

Type

array

$arraySize

$arraySize : integer

The size of the stack

Type

integer

$offset

$offset : integer

The internal pointer offset

Type

integer

$mirrors

$mirrors : array

Bound streams

Type

array

Methods

__construct()

__construct(mixed  $stack = null) 

Create a new ArrayByteStream.

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

Parameters

mixed $stack

of bytes in string or array form, optional

read()

read(integer  $length) : string

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

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

integer $length

Returns

string

write()

write(string  $bytes) : integer|void

Writes $bytes to the end of the stream

Writing may not happen immediately if the stream chooses to buffer. If you want to write these bytes with immediate effect, call \commit() after calling write().

This method returns the sequence ID of the write (i.e. 1 for first, 2 for second, etc etc).

Parameters

string $bytes

Returns

integer|void

commit()

commit() 

Not used

bind()

bind(\Pop\Mail\Transport\Smtp\Stream\Byte\InputInterface  $is) 

Attach $is to this stream.

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

Parameters

\Pop\Mail\Transport\Smtp\Stream\Byte\InputInterface $is

unbind()

unbind(\Pop\Mail\Transport\Smtp\Stream\Byte\InputInterface  $is) 

Remove an already bound stream.

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

\Pop\Mail\Transport\Smtp\Stream\Byte\InputInterface $is

setReadPointer()

setReadPointer(integer  $byteOffset) : boolean

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

Parameters

integer $byteOffset

Returns

boolean

flushBuffers()

flushBuffers() 

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