\Horde_Stream_Temp

Implementation of Horde_Stream for a PHP temporary stream.

Summary

Methods
Properties
Constants
__construct()
__get()
__set()
__clone()
__toString()
add()
length()
getToChar()
peek()
search()
getString()
substring()
getEOL()
getChar()
pos()
rewind()
seek()
end()
eof()
close()
serialize()
unserialize()
$stream
$utf8_char
No constants found
_init()
$_params
$_utf8_char
N/A
No private methods found
No private properties found
N/A

Properties

$stream

$stream : resource

Stream resource.

Type

resource

$utf8_char

$utf8_char : boolean

Parse character as UTF-8 data instead of single byte (@since 1.4.0).

Type

boolean

$_params

$_params : array

Configuration parameters.

Type

array

$_utf8_char

$_utf8_char : boolean

Parse character as UTF-8 data instead of single byte.

Type

boolean

Methods

__construct()

__construct(array  $opts = array()) 

Constructor.

Parameters

array $opts

Additional configuration options:

  - max_memory: (integer) The maximum amount of memory to allocate to
                the PHP temporary stream.

Throws

\Horde_Stream_Exception

__get()

__get(  $name) 

Parameters

$name

__set()

__set(  $name,   $value) 

Parameters

$name
$value

__clone()

__clone() 

__toString()

__toString() : string

String representation of object.

Returns

string —

The full stream converted to a string.

add()

add(mixed  $data, boolean  $reset = false) 

Adds data to the stream.

Parameters

mixed $data

Data to add to the stream. Can be a resource, Horde_Stream object, or a string(-ish) value.

boolean $reset

Reset stream pointer to initial position after adding?

length()

length(boolean  $utf8 = false) : integer

Returns the length of the data. Does not change the stream position.

Parameters

boolean $utf8

If true, determines the UTF-8 length of the stream (as of 1.4.0). If false, determines the byte length of the stream.

Throws

\Horde_Stream_Exception

Returns

integer —

Stream size.

getToChar()

getToChar(string  $end, boolean  $all = true) : string

Get a string up to a certain character (or EOF).

Parameters

string $end

The character to stop reading at. As of 1.4.0, $char can be a multi-character UTF-8 string.

boolean $all

If true, strips all repetitions of $end from the end. If false, stops at the first instance of $end. (@since 1.5.0)

Returns

string —

The string up to $end (stream is positioned after the end character(s), all of which are stripped from the return data).

peek()

peek(integer  $length = 1) : string

Return the current character(s) without moving the pointer.

Parameters

integer $length

The peek length (since 1.4.0).

Returns

string —

The current character.

search()

search(string  $char, boolean  $reverse = false, boolean  $reset = true) : mixed

Search for character(s) and return its position.

Parameters

string $char

The character to search for. As of 1.4.0, $char can be a multi-character UTF-8 string.

boolean $reverse

Do a reverse search?

boolean $reset

Reset the pointer to the original position?

Returns

mixed —

The start position of the search string (integer), or null if character not found.

getString()

getString(integer  $start = null, integer  $end = null) : string

Returns the stream (or a portion of it) as a string. Position values are the byte position in the stream.

Parameters

integer $start

The starting position. If positive, start from this position. If negative, starts this length back from the current position. If null, starts from the current position.

integer $end

The ending position relative to the beginning of the stream (if positive). If negative, end this length back from the end of the stream. If null, reads to the end of the stream.

Returns

string —

A string.

substring()

substring(integer  $start, integer  $length = null, boolean  $char = false) : string

Return part of the stream as a string.

Parameters

integer $start

Start, as an offset from the current postion.

integer $length

Length of string to return. If null, returns rest of the stream. If negative, this many characters will be omitted from the end of the stream.

boolean $char

If true, $start/$length is the length in characters. If false, $start/$length is the length in bytes.

Returns

string —

The substring.

getEOL()

getEOL() : string

Auto-determine the EOL string.

Returns

string —

The EOL string, or null if no EOL found.

getChar()

getChar() : string

Return a character from the string.

Returns

string —

Character (single byte, or UTF-8 character if $utf8_char is true).

pos()

pos() : mixed

Return the current stream pointer position.

Returns

mixed —

The current position (integer), or false.

rewind()

rewind() : boolean

Rewind the internal stream to the beginning.

Returns

boolean —

True if successful.

seek()

seek(integer  $offset, boolean  $curr = true, boolean  $char = false) : boolean

Move internal pointer.

Parameters

integer $offset

The offset.

boolean $curr

If true, offset is from current position. If false, offset is from beginning of stream.

boolean $char

If true, $offset is the length in characters. If false, $offset is the length in bytes.

Returns

boolean —

True if successful.

end()

end(integer  $offset) : boolean

Move internal pointer to the end of the stream.

Parameters

integer $offset

Move this offset from the end.

Returns

boolean —

True if successful.

eof()

eof() : boolean

Has the end of the stream been reached?

Returns

boolean —

True if the end of the stream has been reached.

close()

close() 

Close the stream.

serialize()

serialize() 

unserialize()

unserialize(  $data) 

Parameters

$data

_init()

_init() 

Initialization method.

Throws

\Horde_Stream_Exception