Documentation

ObjectIndex extends AbstractIndexCollection
in package
implements NestedObjectCollectionInterface

AbstractYes

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
template
template
template
extends
implements

Table of Contents

Interfaces

NestedObjectCollectionInterface
Common Interface for both Objects and Collections

Properties

$_key  : string
$type  : string

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

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
phpstan-param

array<TKey,T> $entries

__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>

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>|mixed

chunk()

Split collection into chunks.

public chunk(int $size) : array<string|int, mixed>
Parameters
$size : int

Size of each chunk.

Tags
phpstan-return

array<array<TKey,T>>

Return values
array<string|int, 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
phpstan-return

C[]

Return values
array<string|int, ObjectCollectionInterface>

copy()

Create a copy from this collection by cloning all objects in the collection.

public copy() : static
Return values
static

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
phpstan-return

C

Return values
ObjectCollectionInterface

getIterator()

Required by interface IteratorAggregate.

public getIterator() : mixed
Tags
phpstan-return

Iterator<TKey,T>

Attributes
#[ReturnTypeWillChange]

getKey()

public getKey() : string
Return values
string

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
string

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).

jsonSerialize()

Implements JsonSerializable interface.

public jsonSerialize() : array<string|int, mixed>
Attributes
#[ReturnTypeWillChange]
Return values
array<string|int, mixed>

limit()

public limit(int $start[, int|null $limit = null ]) : static
Parameters
$start : int
$limit : int|null = null
Tags
phpstan-return

static<TKey,T,C>

Return values
static

offsetExists()

Required by interface ArrayAccess.

public offsetExists(string|int|null $offset) : bool
Parameters
$offset : string|int|null
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]
Return values
bool

offsetGet()

Required by interface ArrayAccess.

public offsetGet(string|int|null $offset) : mixed
Parameters
$offset : string|int|null
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]

offsetSet()

Required by interface ArrayAccess.

public offsetSet(string|int|null $offset, mixed $value) : void
Parameters
$offset : string|int|null
$value : mixed
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]

offsetUnset()

Required by interface ArrayAccess.

public offsetUnset(string|int|null $offset) : void
Parameters
$offset : string|int|null
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]

removeElement()

{@inheritDoc}

public removeElement(mixed $element) : mixed
Parameters
$element : mixed

reverse()

Reverse the order of the items.

public reverse() : static
Tags
phpstan-return

static<TKey,T,C>

Return values
static

select()

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
phpstan-return

static<TKey,T,C>

Return values
static

serialize()

public final serialize() : string
Return values
string

set()

{@inheritDoc}

public set(mixed $key, mixed $value) : mixed
Parameters
$key : mixed
$value : mixed

setKey()

public setKey(string $key) : $this
Parameters
$key : string
Return values
$this

setNestedProperty()

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
phpstan-return

C

Return values
ObjectCollectionInterface

shuffle()

Shuffle items.

public shuffle() : static
Tags
phpstan-return

static<TKey,T,C>

Return values
static

slice()

{@inheritDoc}

public slice(mixed $offset[, mixed $length = null ]) : mixed
Parameters
$offset : mixed
$length : mixed = null

unselect()

Un-select items from collection.

public unselect(array<string|int, mixed> $keys) : static
Parameters
$keys : array<string|int, mixed>
Tags
phpstan-return

static<TKey,T,C>

Return values
static

unserialize()

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
phpstan-return

C

Return values
ObjectCollectionInterface

createFrom()

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
phpstan-return

static<TKey,T,C>

Return values
static

getElementMeta()

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
string

getUnserializeAllowedClasses()

protected getUnserializeAllowedClasses() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|bool

isAllowedElement()

protected abstract isAllowedElement(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

loadElement()

protected abstract loadElement(string $key, mixed $value) : mixed|null
Parameters
$key : string
$value : mixed
Return values
mixed|null

loadElements()

protected abstract loadElements([array<string|int, mixed>|null $entries = null ]) : array<string|int, mixed>
Parameters
$entries : array<string|int, mixed>|null = null
Tags
phpstan-return

array<TKey,T>

Return values
array<string|int, mixed>

setEntries()

protected setEntries(array<string|int, mixed> $entries) : void
Parameters
$entries : array<string|int, mixed>
Tags
phpstan-param

array<TKey,T> $entries


        
On this page

Search results