Documentation

Horde_Stream_Existing extends Horde_Stream
in package

Implementation of Horde_Stream for an existing stream resource. This resource will be directly modified when manipulating using this class.

Tags
since
1.2.0
author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

2012-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Table of Contents

$stream  : resource
Stream resource.
$utf8_char  : bool
$_params  : array<string|int, mixed>
Configuration parameters.
$_utf8_char  : bool
Parse character as UTF-8 data instead of single byte.
__clone()  : mixed
__construct()  : mixed
Constructor.
__get()  : mixed
__serialize()  : array<string|int, mixed>
__set()  : mixed
__toString()  : string
String representation of object.
__unserialize()  : void
add()  : mixed
Adds data to the stream.
close()  : mixed
Close the stream.
end()  : bool
Move internal pointer to the end of the stream.
eof()  : bool
Has the end of the stream been reached?
getChar()  : string
Return a character from the string.
getEOL()  : string
Auto-determine the EOL string.
getString()  : string
Returns the stream (or a portion of it) as a string. Position values are the byte position in the stream.
getToChar()  : string
Get a string up to a certain character (or EOF).
length()  : int
Returns the length of the data. Does not change the stream position.
peek()  : string
Return the current character(s) without moving the pointer.
pos()  : mixed
Return the current stream pointer position.
rewind()  : bool
Rewind the internal stream to the beginning.
search()  : mixed
Search for character(s) and return its position.
seek()  : bool
Move internal pointer.
serialize()  : mixed
substring()  : string
Return part of the stream as a string.
unserialize()  : mixed
_init()  : mixed
Initialization method.

Properties

$stream

Stream resource.

public resource $stream

$utf8_char

public bool $utf8_char

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

$_params

Configuration parameters.

protected array<string|int, mixed> $_params

$_utf8_char

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

protected bool $_utf8_char = \false

Methods

__clone()

public __clone() : mixed
Return values
mixed

__construct()

Constructor.

public __construct([array<string|int, mixed> $opts = array() ]) : mixed
Parameters
$opts : array<string|int, mixed> = array()

Additional configuration options:

  • stream: (resource) [REQUIRED] The stream resource.
Tags
throws
InvalidArgumentException
Return values
mixed

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__set()

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed
Return values
mixed

__toString()

String representation of object.

public __toString() : string
Tags
since
1.1.0
Return values
string

The full stream converted to a string.

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

add()

Adds data to the stream.

public add(mixed $data[, bool $reset = false ]) : mixed
Parameters
$data : mixed

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

$reset : bool = false

Reset stream pointer to initial position after adding?

Return values
mixed

close()

Close the stream.

public close() : mixed
Tags
since
1.4.0
Return values
mixed

end()

Move internal pointer to the end of the stream.

public end(int $offset) : bool
Parameters
$offset : int

Move this offset from the end.

Tags
since
1.4.0
Return values
bool

True if successful.

eof()

Has the end of the stream been reached?

public eof() : bool
Tags
since
1.4.0
Return values
bool

True if the end of the stream has been reached.

getChar()

Return a character from the string.

public getChar() : string
Tags
since
1.4.0
Return values
string

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

getEOL()

Auto-determine the EOL string.

public getEOL() : string
Tags
since
1.3.0
Return values
string

The EOL string, or null if no EOL found.

getString()

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

public getString([int $start = null ][, int $end = null ]) : string
Parameters
$start : int = null

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.

$end : int = null

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.

Return values
string

A string.

getToChar()

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

public getToChar(string $end[, bool $all = true ]) : string
Parameters
$end : string

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

$all : bool = true

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

Return values
string

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

length()

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

public length([bool $utf8 = false ]) : int
Parameters
$utf8 : bool = false

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

Tags
throws
Horde_Stream_Exception
Return values
int

Stream size.

peek()

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

public peek([int $length = 1 ]) : string
Parameters
$length : int = 1

The peek length (since 1.4.0).

Return values
string

The current character.

pos()

Return the current stream pointer position.

public pos() : mixed
Tags
since
1.4.0
Return values
mixed

The current position (integer), or false.

rewind()

Rewind the internal stream to the beginning.

public rewind() : bool
Tags
since
1.4.0
Return values
bool

True if successful.

Search for character(s) and return its position.

public search(string $char[, bool $reverse = false ][, bool $reset = true ]) : mixed
Parameters
$char : string

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

$reverse : bool = false

Do a reverse search?

$reset : bool = true

Reset the pointer to the original position?

Return values
mixed

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

seek()

Move internal pointer.

public seek(int $offset[, bool $curr = true ][, bool $char = false ]) : bool
Parameters
$offset : int

The offset.

$curr : bool = true

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

$char : bool = false

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

Tags
since
1.4.0
Return values
bool

True if successful.

serialize()

public serialize() : mixed
Return values
mixed

substring()

Return part of the stream as a string.

public substring(int $start[, int $length = null ][, bool $char = false ]) : string
Parameters
$start : int

Start, as an offset from the current postion.

$length : int = null

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.

$char : bool = false

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

Tags
since
1.4.0
Return values
string

The substring.

unserialize()

public unserialize(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

_init()

Initialization method.

protected _init() : mixed
Return values
mixed

Search results