Interface

TRex\Core\IObjects

interface IObjects implements IIterator, IteratorAggregate, ArrayAccess, IKeyAccessor, Countable, IIteratorSorter, IObjectsComparator, IObjectsModifier, IObjectsSearcher

IObjects is a oriented object array.

This handles a list like an object.

Methods

bool exist(mixed $key)

Checks if the offset exists.

from IIterator
mixed get(mixed $key)

Gets the value from the provided offset.

from IIterator
mixed key()

Gets the current array key.

from IIterator
mixed current()

Gets the current array entry.

from IIterator
next()

Sets the iterator to the next entry.

from IIterator
rewind()

Rewinds the iterator to the beginning.

from IIterator
seek(int $index)

Sets the iterator to a specified offset.

from IIterator
bool valid()

Checks if the array contains any more entries.

from IIterator
addAt(mixed $key, mixed $value)

Sets a value for a specified offset.

from IIterator
removeAt(mixed $key)

Unsets a value for an offset.

from IIterator
int count()

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

from IIterator
array toArray()

{@inheritDoc}

from IIterator
array getKeys()

Returns all keys.

from IKeyAccessor
mixed|null getKey(int $index)

Returns the key associated to the specified offset.

from IKeyAccessor
mixed|null getFirstKey()

Gets the first key.

from IKeyAccessor
mixed|null getLastKey()

Get the last key.

from IKeyAccessor
IObjects reindex()

Reindex the key numerically.

from IIteratorSorter
IObjects sort(SortType $type = null, callable|int $option = SORT_NATURAL)

Sorts values.

from IIteratorSorter
IObjects reverse(bool $areKeysPreserved = true)

Reverses the order of the values.

from IIteratorSorter
IObjects merge(IObjects $objects)

Merges a series of IObjects.

from IObjectsComparator
IObjects mergeA(IObjects $objects)

Merges a series of IObjects.

from IObjectsComparator
IObjects diff(IObjects $objects)

Compares current IObject values with the IObject params.

from IObjectsComparator
IObjects diffA(IObjects $objects)

Compares current IObject values and keys with the IObject params.

from IObjectsComparator
IObjects diffK(IObjects $objects)

Compares current IObject keys with the IObject params.

from IObjectsComparator
IObjects intersect(IObjects $objects)

Compares current IObject values with the IObject params.

from IObjectsComparator
IObjects intersectA(IObjects $objects)

Compares current IObject values and keys with the IObject params.

from IObjectsComparator
IObjects intersectK(IObjects $objects)

Compares current IObject keys with the IObject params.

from IObjectsComparator
IObjects extract(int $startIndex, int $length, bool $areKeysPreserved = true)

Extracts the sequence of elements.

from IObjectsModifier
IObjects each(Closure $callback)

Executes the callback for every value.

from IObjectsModifier
IObjects filter(Closure $callback = null)

Executes the callback for every value.

from IObjectsModifier
bool has(string $value, string $searchMode = self::STRICT_SEARCH_MODE)

Indicates whether the value is present.

from IObjectsSearcher
array search(string $value, string $searchMode = self::STRICT_SEARCH_MODE)

Searches the keys for the value.

from IObjectsSearcher
mixed|null getByIndex(int $index)

Gets the value of the associate index.

mixed|null first()

Gets the first value.

mixed|null last()

Gets the last value.

addFirst(mixed $value)

Adds values at the beginning of the list.

addLast(mixed $value)

Adds values at the end of the list.

removeFirst()

Removes first value of the list.

removeLast()

Removes last value of the list.

Details

in IIterator at line 19
public bool exist(mixed $key)

Checks if the offset exists.

Parameters

mixed $key

Return Value

bool

in IIterator at line 27
public mixed get(mixed $key)

Gets the value from the provided offset.

Parameters

mixed $key

Return Value

mixed

in IIterator at line 34
public mixed key()

Gets the current array key.

Return Value

mixed

in IIterator at line 41
public mixed current()

Gets the current array entry.

Return Value

mixed

in IIterator at line 46
public next()

Sets the iterator to the next entry.

in IIterator at line 51
public rewind()

Rewinds the iterator to the beginning.

in IIterator at line 58
public seek(int $index)

Sets the iterator to a specified offset.

Parameters

int $index

in IIterator at line 65
public bool valid()

Checks if the array contains any more entries.

Return Value

bool

in IIterator at line 73
public addAt(mixed $key, mixed $value)

Sets a value for a specified offset.

Parameters

mixed $key
mixed $value

in IIterator at line 80
public removeAt(mixed $key)

Unsets a value for an offset.

Parameters

mixed $key

in IIterator at line 87
public int count()

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

Return Value

int

in IIterator at line 94
public array toArray()

{@inheritDoc}

Return Value

array

in IKeyAccessor at line 18
public array getKeys()

Returns all keys.

Return Value

array

in IKeyAccessor at line 29
public mixed|null getKey(int $index)

Returns the key associated to the specified offset.

This key may be the offset or an associative key. Resolves the negative offset.

Parameters

int $index

Return Value

mixed|null

in IKeyAccessor at line 36
public mixed|null getFirstKey()

Gets the first key.

Return Value

mixed|null

in IKeyAccessor at line 43
public mixed|null getLastKey()

Get the last key.

Return Value

mixed|null

in IIteratorSorter at line 21
public IObjects reindex()

Reindex the key numerically.

Returns an IObjects with the same values but indexed keys.

Return Value

IObjects

in IIteratorSorter at line 34
public IObjects sort(SortType $type = null, callable|int $option = SORT_NATURAL)

Sorts values.

For more info on sort, see PHP documentation. Returns an IObjects with sorted values. $type describes the type of sorting. (value/key/associative) $option is a PHP sort option or a callback.

Parameters

SortType $type
callable|int $option

Return Value

IObjects

in IIteratorSorter at line 42
public IObjects reverse(bool $areKeysPreserved = true)

Reverses the order of the values.

Parameters

bool $areKeysPreserved

Return Value

IObjects

in IObjectsComparator at line 19
public IObjects merge(IObjects $objects)

Merges a series of IObjects.

Does not preserve keys.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsComparator at line 28
public IObjects mergeA(IObjects $objects)

Merges a series of IObjects.

Preserves keys.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsComparator at line 37
public IObjects diff(IObjects $objects)

Compares current IObject values with the IObject params.

Returns all the values of current IObject that are not present in the IObject params.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsComparator at line 46
public IObjects diffA(IObjects $objects)

Compares current IObject values and keys with the IObject params.

Returns all the values of current IObject that are not present in the IObject params.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsComparator at line 55
public IObjects diffK(IObjects $objects)

Compares current IObject keys with the IObject params.

Returns all the values of current IObject that are not present in the IObject params.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsComparator at line 64
public IObjects intersect(IObjects $objects)

Compares current IObject values with the IObject params.

Returns all the values of current IObject that are present in the IObject params.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsComparator at line 73
public IObjects intersectA(IObjects $objects)

Compares current IObject values and keys with the IObject params.

Returns all the values of current IObject that are present in the IObject params.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsComparator at line 82
public IObjects intersectK(IObjects $objects)

Compares current IObject keys with the IObject params.

Returns all the values of current IObject that are present in the IObject params.

Parameters

IObjects $objects

Return Value

IObjects

in IObjectsModifier at line 21
public IObjects extract(int $startIndex, int $length, bool $areKeysPreserved = true)

Extracts the sequence of elements.

Starts at index $startIndex and stop after $length keys.

Parameters

int $startIndex
int $length
bool $areKeysPreserved

Return Value

IObjects

in IObjectsModifier at line 30
public IObjects each(Closure $callback)

Executes the callback for every value.

Returns an IObjects with the result of each callback call.

Parameters

Closure $callback

Return Value

IObjects

in IObjectsModifier at line 40
public IObjects filter(Closure $callback = null)

Executes the callback for every value.

Returns an IObjects with the value of which callback has return true. If no callback is passed, filters on the value itself.

Parameters

Closure $callback

Return Value

IObjects

in IObjectsSearcher at line 37
public bool has(string $value, string $searchMode = self::STRICT_SEARCH_MODE)

Indicates whether the value is present.

Parameters

string $value
string $searchMode

Return Value

bool

Searches the keys for the value.

Parameters

string $value
string $searchMode

Return Value

array

at line 38
public mixed|null getByIndex(int $index)

Gets the value of the associate index.

$index can be specified even the keys are associative. If the index is 0, the method will return the first value, ... If the index is -1, the method will return the last value, ...

Parameters

int $index

Return Value

mixed|null

at line 45
public mixed|null first()

Gets the first value.

Return Value

mixed|null

at line 52
public mixed|null last()

Gets the last value.

Return Value

mixed|null

at line 59
public addFirst(mixed $value)

Adds values at the beginning of the list.

Parameters

mixed $value

at line 66
public addLast(mixed $value)

Adds values at the end of the list.

Parameters

mixed $value

at line 71
public removeFirst()

Removes first value of the list.

at line 76
public removeLast()

Removes last value of the list.