Class

TRex\Iterator\IteratorAdapter

class IteratorAdapter extends Object implements IObjectsIterator

Adapts \ArrayIterator to TRex\Iterator IObjectsIterator.

Methods

__construct(ArrayIterator $arrayIterator)

Constructor.

mixed __get(string $propertyName)

See PHP doc.

from Object
mixed __set(string $propertyName, mixed $value)

See PHP doc.

from Object
mixed __call(string $methodName, array $args)

See PHP doc.

from Object
boolean isDynamic()

Indicates whether the current object has dynamic properties access.

from Object
setDynamic(boolean $isDynamic)

Sets dynamic properties access.

from Object
addMethod(string $name, Closure $method)

Adds a dynamic method to the object.

from Object
array toArray()

Converts an object to an array.

Json toJson(int $options = JSON_PRETTY_PRINT)

Converts an object to a Json object.

from Object
string __toString()

See PHP doc.

from Object
bool exist(mixed $key)

Checks if the offset exists.

mixed get(mixed $key)

Gets the value from the provided offset.

addAt(mixed $key, mixed $value)

Sets a value for a specified offset.

removeAt(mixed $key)

Unsets a value for an offset.

mixed key()

Gets the current array key.

mixed current()

Gets the current array entry.

next()

Sets the iterator to the next entry.

rewind()

Rewinds the iterator to the beginning.

seek($index $index)

Sets the iterator to a specified offset.

bool valid()

Checks if the array contains any more entries.

int count()

Gets the number of elements in the array, or the number of public properties in the object.

Details

at line 29
public __construct(ArrayIterator $arrayIterator)

Constructor.

$data is initial data to set in the object. Keys are property names, and values are initial property values. $data could be a JSON string, an array or an array castable object.

Parameters

ArrayIterator $arrayIterator

in Object at line 58
public mixed __get(string $propertyName)

See PHP doc.

Parameters

string $propertyName

Return Value

mixed

Exceptions

RuntimeException

in Object at line 78
public mixed __set(string $propertyName, mixed $value)

See PHP doc.

Parameters

string $propertyName
mixed $value

Return Value

mixed

Exceptions

RuntimeException

in Object at line 101
public mixed __call(string $methodName, array $args)

See PHP doc.

Call dynamically a method added with self::addMethod(). After having added a method, it is possible to call it like a declared method $object->newMethod($arg)

Parameters

string $methodName
array $args

Return Value

mixed

Exceptions

RuntimeException

in Object at line 116
public boolean isDynamic()

Indicates whether the current object has dynamic properties access.

Return Value

boolean

in Object at line 126
public setDynamic(boolean $isDynamic)

Sets dynamic properties access.

Parameters

boolean $isDynamic

in Object at line 137
public addMethod(string $name, Closure $method)

Adds a dynamic method to the object.

Parameters

string $name
Closure $method

at line 148
public array toArray()

Converts an object to an array.

The exported array contains all property values of the class and its parents, which are not transient.

Return Value

array

in Object at line 157
public Json toJson(int $options = JSON_PRETTY_PRINT)

Converts an object to a Json object.

The exported data contains all property values ofn the class and its parents, who are not transient.

Parameters

int $options

Return Value

Json

in Object at line 170
public string __toString()

See PHP doc.

Return Value

string

at line 40
public bool exist(mixed $key)

Checks if the offset exists.

Parameters

mixed $key

Return Value

bool

at line 51
public mixed get(mixed $key)

Gets the value from the provided offset.

Parameters

mixed $key

Return Value

mixed

at line 62
public addAt(mixed $key, mixed $value)

Sets a value for a specified offset.

Parameters

mixed $key
mixed $value

at line 72
public removeAt(mixed $key)

Unsets a value for an offset.

Parameters

mixed $key

at line 82
public mixed key()

Gets the current array key.

Return Value

mixed

at line 92
public mixed current()

Gets the current array entry.

Return Value

mixed

at line 100
public next()

Sets the iterator to the next entry.

at line 108
public rewind()

Rewinds the iterator to the beginning.

at line 118
public seek($index $index)

Sets the iterator to a specified offset.

Parameters

$index $index

at line 128
public bool valid()

Checks if the array contains any more entries.

Return Value

bool

at line 138
public int count()

Gets the number of elements in the array, or the number of public properties in the object.

Return Value

int