ObjectIndex
extends AbstractIndexCollection
in package
implements
NestedObjectCollectionInterface
Keeps index of objects instead of collection of objects. This class allows you to keep a list of objects and load them on demand. The class can be used seemingly instead of ObjectCollection when the objects haven't been loaded yet.
This is an abstract class and has some protected abstract methods to load objects which you need to implement in order to use the class.
Tags
Table of Contents
Interfaces
- NestedObjectCollectionInterface
- Common Interface for both Objects and Collections
Properties
Methods
- __call() : mixed
- __construct() : mixed
- Initializes a new IndexCollection.
- __serialize() : array<string|int, mixed>
- __toString() : string
- Returns a string representation of this object.
- __unserialize() : void
- add() : mixed
- {@inheritDoc}
- call() : array<string|int, mixed>|mixed
- chunk() : array<string|int, mixed>
- Split collection into chunks.
- clear() : mixed
- {@inheritDoc}
- collectionGroup() : array<string|int, ObjectCollectionInterface>
- Group items in the collection by a field and return them as associated array of collections.
- contains() : mixed
- {@inheritDoc}
- containsKey() : mixed
- {@inheritDoc}
- copy() : static
- Create a copy from this collection by cloning all objects in the collection.
- count() : mixed
- {@inheritDoc}
- current() : mixed
- {@inheritDoc}
- defNestedProperty() : ObjectCollectionInterface
- defProperty() : ObjectCollectionInterface
- exists() : mixed
- {@inheritDoc}
- filter() : mixed
- {@inheritDoc}
- first() : mixed
- {@inheritDoc}
- forAll() : mixed
- {@inheritDoc}
- get() : mixed
- {@inheritDoc}
- getIterator() : mixed
- Required by interface IteratorAggregate.
- getKey() : string
- getKeys() : mixed
- {@inheritDoc}
- getNestedProperty() : array<string|int, mixed>
- getObjectKeys() : array<string|int, mixed>
- getProperty() : array<string|int, mixed>
- getType() : string
- getValues() : mixed
- {@inheritDoc}
- group() : array<string|int, mixed>
- Group items in the collection by a field and return them as associated array.
- hasNestedProperty() : array<string|int, bool>
- hasProperty() : array<string|int, bool>
- indexOf() : mixed
- {@inheritDoc}
- isEmpty() : mixed
- {@inheritDoc}
- jsonSerialize() : array<string|int, mixed>
- Implements JsonSerializable interface.
- key() : mixed
- {@inheritDoc}
- last() : mixed
- {@inheritDoc}
- limit() : static
- map() : mixed
- {@inheritDoc}
- matching() : ObjectCollectionInterface
- next() : mixed
- {@inheritDoc}
- offsetExists() : bool
- Required by interface ArrayAccess.
- offsetGet() : mixed
- Required by interface ArrayAccess.
- offsetSet() : void
- Required by interface ArrayAccess.
- offsetUnset() : void
- Required by interface ArrayAccess.
- orderBy() : ObjectCollectionInterface
- partition() : mixed
- {@inheritDoc}
- remove() : mixed
- {@inheritDoc}
- removeElement() : mixed
- {@inheritDoc}
- reverse() : static
- Reverse the order of the items.
- select() : static
- Select items from collection.
- serialize() : string
- set() : mixed
- {@inheritDoc}
- setKey() : $this
- setNestedProperty() : ObjectCollectionInterface
- setProperty() : ObjectCollectionInterface
- shuffle() : static
- Shuffle items.
- slice() : mixed
- {@inheritDoc}
- toArray() : mixed
- {@inheritDoc}
- unselect() : static
- Un-select items from collection.
- unserialize() : void
- unsetNestedProperty() : ObjectCollectionInterface
- unsetProperty() : ObjectCollectionInterface
- createFrom() : static
- Creates a new instance from the specified elements.
- getCurrentKey() : string
- getElementMeta() : mixed
- getEntries() : array<string|int, mixed>
- getTypePrefix() : string
- getUnserializeAllowedClasses() : array<string|int, mixed>|bool
- isAllowedElement() : bool
- loadCollection() : CollectionInterface
- loadElement() : mixed|null
- loadElements() : array<string|int, mixed>
- setEntries() : void
Properties
$_key
protected
string
$_key
$type
protected
static string
$type
Methods
__call()
public
abstract __call(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
__construct()
Initializes a new IndexCollection.
public
__construct([array<string|int, mixed> $entries = [] ]) : mixed
Parameters
- $entries : array<string|int, mixed> = []
Tags
__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__toString()
Returns a string representation of this object.
public
__toString() : string
Attributes
- #[ReturnTypeWillChange]
Return values
string__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
add()
{@inheritDoc}
public
add(mixed $element) : mixed
Parameters
- $element : mixed
call()
public
call(string $method[, array<string|int, mixed> $arguments = [] ]) : array<string|int, mixed>|mixed
Parameters
- $method : string
- $arguments : array<string|int, mixed> = []
Return values
array<string|int, mixed>|mixedchunk()
Split collection into chunks.
public
chunk(int $size) : array<string|int, mixed>
Parameters
- $size : int
-
Size of each chunk.
Tags
Return values
array<string|int, mixed>clear()
{@inheritDoc}
public
clear() : mixed
collectionGroup()
Group items in the collection by a field and return them as associated array of collections.
public
collectionGroup(string $property) : array<string|int, ObjectCollectionInterface>
Parameters
- $property : string
Tags
Return values
array<string|int, ObjectCollectionInterface>contains()
{@inheritDoc}
public
contains(mixed $element) : mixed
Parameters
- $element : mixed
containsKey()
{@inheritDoc}
public
containsKey(mixed $key) : mixed
Parameters
- $key : mixed
copy()
Create a copy from this collection by cloning all objects in the collection.
public
copy() : static
Return values
staticcount()
{@inheritDoc}
public
count() : mixed
Attributes
- #[ReturnTypeWillChange]
current()
{@inheritDoc}
public
current() : mixed
Attributes
- #[ReturnTypeWillChange]
defNestedProperty()
public
defNestedProperty(string $property, mixed $default[, string|null $separator = null ]) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be defined.
- $default : mixed
-
Default value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
ObjectCollectionInterfacedefProperty()
public
defProperty(string $property, mixed $default) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be defined.
- $default : mixed
-
Default value.
Tags
Return values
ObjectCollectionInterfaceexists()
{@inheritDoc}
public
exists(Closure $p) : mixed
Parameters
- $p : Closure
filter()
{@inheritDoc}
public
filter(Closure $p) : mixed
Parameters
- $p : Closure
first()
{@inheritDoc}
public
first() : mixed
forAll()
{@inheritDoc}
public
forAll(Closure $p) : mixed
Parameters
- $p : Closure
get()
{@inheritDoc}
public
get(mixed $key) : mixed
Parameters
- $key : mixed
getIterator()
Required by interface IteratorAggregate.
public
getIterator() : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
getKey()
public
getKey() : string
Return values
stringgetKeys()
{@inheritDoc}
public
getKeys() : mixed
getNestedProperty()
public
getNestedProperty(string $property[, mixed $default = null ][, string|null $separator = null ]) : array<string|int, mixed>
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if property has not been set.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
array<string|int, mixed> —Property values.
getObjectKeys()
public
getObjectKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>getProperty()
public
getProperty(string $property[, mixed $default = null ]) : array<string|int, mixed>
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if property has not been set.
Return values
array<string|int, mixed> —Property values.
getType()
public
getType([bool $prefix = true ]) : string
Parameters
- $prefix : bool = true
Return values
stringgetValues()
{@inheritDoc}
public
getValues() : mixed
group()
Group items in the collection by a field and return them as associated array.
public
group(string $property) : array<string|int, mixed>
Parameters
- $property : string
Return values
array<string|int, mixed>hasNestedProperty()
public
hasNestedProperty(string $property[, string|null $separator = null ]) : array<string|int, bool>
Parameters
- $property : string
-
Object property name.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
array<string|int, bool> —True if property has been defined (can be null).
hasProperty()
public
hasProperty(string $property) : array<string|int, bool>
Parameters
- $property : string
-
Object property name.
Return values
array<string|int, bool> —True if property has been defined (can be null).
indexOf()
{@inheritDoc}
public
indexOf(mixed $element) : mixed
Parameters
- $element : mixed
isEmpty()
{@inheritDoc}
public
isEmpty() : mixed
jsonSerialize()
Implements JsonSerializable interface.
public
jsonSerialize() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>key()
{@inheritDoc}
public
key() : mixed
Attributes
- #[ReturnTypeWillChange]
last()
{@inheritDoc}
public
last() : mixed
limit()
public
limit(int $start[, int|null $limit = null ]) : static
Parameters
- $start : int
- $limit : int|null = null
Tags
Return values
staticmap()
{@inheritDoc}
public
map(Closure $func) : mixed
Parameters
- $func : Closure
matching()
public
matching(Criteria $criteria) : ObjectCollectionInterface
Parameters
- $criteria : Criteria
Tags
Return values
ObjectCollectionInterfacenext()
{@inheritDoc}
public
next() : mixed
Attributes
- #[ReturnTypeWillChange]
offsetExists()
Required by interface ArrayAccess.
public
offsetExists(string|int|null $offset) : bool
Parameters
- $offset : string|int|null
Tags
Attributes
- #[ReturnTypeWillChange]
Return values
booloffsetGet()
Required by interface ArrayAccess.
public
offsetGet(string|int|null $offset) : mixed
Parameters
- $offset : string|int|null
Tags
Attributes
- #[ReturnTypeWillChange]
offsetSet()
Required by interface ArrayAccess.
public
offsetSet(string|int|null $offset, mixed $value) : void
Parameters
- $offset : string|int|null
- $value : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
offsetUnset()
Required by interface ArrayAccess.
public
offsetUnset(string|int|null $offset) : void
Parameters
- $offset : string|int|null
Tags
Attributes
- #[ReturnTypeWillChange]
orderBy()
public
orderBy(array<string|int, mixed> $ordering) : ObjectCollectionInterface
Parameters
- $ordering : array<string|int, mixed>
Tags
Return values
ObjectCollectionInterfacepartition()
{@inheritDoc}
public
partition(Closure $p) : mixed
Parameters
- $p : Closure
remove()
{@inheritDoc}
public
remove(mixed $key) : mixed
Parameters
- $key : mixed
removeElement()
{@inheritDoc}
public
removeElement(mixed $element) : mixed
Parameters
- $element : mixed
reverse()
Reverse the order of the items.
public
reverse() : static
Tags
Return values
staticselect()
Select items from collection.
public
select(array<string|int, mixed> $keys) : static
Collection is returned in the order of $keys given to the function.
Parameters
- $keys : array<string|int, mixed>
Tags
Return values
staticserialize()
public
final serialize() : string
Return values
stringset()
{@inheritDoc}
public
set(mixed $key, mixed $value) : mixed
Parameters
- $key : mixed
- $value : mixed
setKey()
public
setKey(string $key) : $this
Parameters
- $key : string
Return values
$thissetNestedProperty()
public
setNestedProperty(string $property, mixed $value[, string|null $separator = null ]) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
ObjectCollectionInterfacesetProperty()
public
setProperty(string $property, string $value) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be updated.
- $value : string
-
New value.
Tags
Return values
ObjectCollectionInterfaceshuffle()
Shuffle items.
public
shuffle() : static
Tags
Return values
staticslice()
{@inheritDoc}
public
slice(mixed $offset[, mixed $length = null ]) : mixed
Parameters
- $offset : mixed
- $length : mixed = null
toArray()
{@inheritDoc}
public
toArray() : mixed
unselect()
Un-select items from collection.
public
unselect(array<string|int, mixed> $keys) : static
Parameters
- $keys : array<string|int, mixed>
Tags
Return values
staticunserialize()
public
final unserialize(string $serialized) : void
Parameters
- $serialized : string
unsetNestedProperty()
public
unsetNestedProperty(string $property[, string|null $separator = null ]) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be unset.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
ObjectCollectionInterfaceunsetProperty()
public
unsetProperty(string $property) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be unset.
Tags
Return values
ObjectCollectionInterfacecreateFrom()
Creates a new instance from the specified elements.
protected
createFrom(array<string|int, mixed> $entries) : static
This method is provided for derived classes to specify how a new instance should be created when constructor semantics have changed.
Parameters
- $entries : array<string|int, mixed>
-
Elements.
Tags
Return values
staticgetCurrentKey()
protected
getCurrentKey(FlexObjectInterface $element) : string
Parameters
- $element : FlexObjectInterface
Tags
Return values
stringgetElementMeta()
protected
abstract getElementMeta(mixed $element) : mixed
Parameters
- $element : mixed
getEntries()
protected
getEntries() : array<string|int, mixed>
Return values
array<string|int, mixed>getTypePrefix()
protected
getTypePrefix() : string
Return values
stringgetUnserializeAllowedClasses()
protected
getUnserializeAllowedClasses() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|boolisAllowedElement()
protected
abstract isAllowedElement(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolloadCollection()
protected
abstract loadCollection([array<string|int, mixed>|null $entries = null ]) : CollectionInterface
Parameters
- $entries : array<string|int, mixed>|null = null
Tags
Return values
CollectionInterfaceloadElement()
protected
abstract loadElement(string $key, mixed $value) : mixed|null
Parameters
- $key : string
- $value : mixed
Return values
mixed|nullloadElements()
protected
abstract loadElements([array<string|int, mixed>|null $entries = null ]) : array<string|int, mixed>
Parameters
- $entries : array<string|int, mixed>|null = null
Tags
Return values
array<string|int, mixed>setEntries()
protected
setEntries(array<string|int, mixed> $entries) : void
Parameters
- $entries : array<string|int, mixed>