ObjectCollection
extends ArrayCollection
in package
implements
NestedObjectCollectionInterface
uses
ObjectCollectionTrait, NestedPropertyCollectionTrait
Class contains a collection of objects.
Tags
Table of Contents
Interfaces
- NestedObjectCollectionInterface
- Common Interface for both Objects and Collections
Properties
Methods
- __construct() : mixed
- __serialize() : array<string|int, mixed>
- __toString() : string
- Returns a string representation of this object.
- __unserialize() : void
- call() : array<string|int, mixed>
- chunk() : array<string|int, mixed>
- Split collection into chunks.
- collectionGroup() : array<string|int, static>
- Group items in the collection by a field and return them as associated array of collections.
- copy() : T>
- Create a copy from this collection by cloning all objects in the collection.
- defNestedProperty() : $this
- defProperty() : $this
- doDefProperty() : $this
- doGetProperty() : array<string|int, mixed>
- doHasProperty() : array<string|int, bool>
- doSetProperty() : $this
- doUnsetProperty() : $this
- getKey() : string
- getNestedProperty() : array<string|int, mixed>
- getObjectKeys() : array<string|int, string>
- getProperty() : array<string|int, mixed>
- getType() : string
- group() : array<string|int, mixed>
- Group items in the collection by a field and return them as associated array.
- hasKey() : bool
- hasNestedProperty() : array<string|int, mixed>
- hasProperty() : array<string|int, bool>
- jsonSerialize() : array<string|int, mixed>
- Implements JsonSerializable interface.
- limit() : static
- matching() : static
- orderBy() : static
- reverse() : static
- Reverse the order of the items.
- select() : static
- Select items from collection.
- setKey() : $this
- setNestedProperty() : $this
- setProperty() : $this
- shuffle() : static
- Shuffle items.
- unselect() : static
- Un-select items from collection.
- unsetNestedProperty() : $this
- unsetProperty() : $this
- doSerialize() : array<string|int, mixed>
- doUnserialize() : void
- getElements() : array<string|int, mixed>
- getTypePrefix() : string
- setElements() : array<string|int, mixed>
Properties
$type
protected
static string
$type
$_key
private
string
$_key
Methods
__construct()
public
__construct([array<string|int, mixed> $elements = [] ][, string|null $key = null ]) : mixed
Parameters
- $elements : array<string|int, mixed> = []
- $key : string|null = null
Tags
__serialize()
public
final __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
final __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>
Parameters
- $method : string
-
Method name.
- $arguments : array<string|int, mixed> = []
-
List of arguments passed to the function.
Return values
array<string|int, mixed> —Return values.
chunk()
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>collectionGroup()
Group items in the collection by a field and return them as associated array of collections.
public
collectionGroup(string $property) : array<string|int, static>
Parameters
- $property : string
Tags
Return values
array<string|int, static>copy()
Create a copy from this collection by cloning all objects in the collection.
public
copy() : T>
Return values
T>defNestedProperty()
public
defNestedProperty(string $property, string $default[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $default : string
-
Default value.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
$thisdefProperty()
public
defProperty(string $property, mixed $default) : $this
Parameters
- $property : string
-
Object property to be defined.
- $default : mixed
-
Default value.
Return values
$thisdoDefProperty()
public
doDefProperty(string $property, mixed $default) : $this
Parameters
- $property : string
-
Object property to be updated.
- $default : mixed
-
Default value.
Return values
$thisdoGetProperty()
public
& doGetProperty(string $property[, mixed $default = null ][, bool $doCreate = false ]) : array<string|int, mixed>
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if not set.
- $doCreate : bool = false
-
Not being used.
Return values
array<string|int, mixed> —Key/Value pairs of the properties.
doHasProperty()
public
doHasProperty(string $property) : array<string|int, bool>
Parameters
- $property : string
-
Object property to be matched.
Return values
array<string|int, bool> —Key/Value pairs of the properties.
doSetProperty()
public
doSetProperty(string $property, mixed $value) : $this
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
Return values
$thisdoUnsetProperty()
public
doUnsetProperty(string $property) : $this
Parameters
- $property : string
-
Object property to be updated.
Return values
$thisgetKey()
public
getKey() : string
Return values
stringgetNestedProperty()
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 not set.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
array<string|int, mixed> —Key/Value pairs of the properties.
getObjectKeys()
public
getObjectKeys() : array<string|int, string>
Return values
array<string|int, string>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
stringgroup()
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
Tags
Return values
array<string|int, mixed>hasKey()
public
hasKey() : bool
Return values
boolhasNestedProperty()
public
hasNestedProperty(string $property[, string|null $separator = null ]) : array<string|int, mixed>
Parameters
- $property : string
-
Object property to be matched.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
array<string|int, mixed> —Key/Value pairs of the properties.
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
Return values
staticmatching()
public
matching(Criteria $criteria) : static
Parameters
- $criteria : Criteria
Tags
Return values
staticorderBy()
public
orderBy(array<string|int, mixed> $ordering) : static
Parameters
- $ordering : array<string|int, mixed>
Tags
Return values
staticreverse()
Reverse the order of the items.
public
reverse() : static
Tags
Return values
staticselect()
Select items from collection.
public
select(array<int, string> $keys) : static
Collection is returned in the order of $keys given to the function.
Parameters
- $keys : array<int, string>
Tags
Return values
staticsetKey()
public
setKey(string $key) : $this
Parameters
- $key : string
Return values
$thissetNestedProperty()
public
setNestedProperty(string $property, mixed $value[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
$thissetProperty()
public
setProperty(string $property, mixed $value) : $this
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
Return values
$thisshuffle()
Shuffle items.
public
shuffle() : static
Tags
Return values
staticunselect()
Un-select items from collection.
public
unselect(array<string|int, int|string> $keys) : static
Parameters
- $keys : array<string|int, int|string>
Tags
Return values
staticunsetNestedProperty()
public
unsetNestedProperty(string $property[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
$thisunsetProperty()
public
unsetProperty(string $property) : $this
Parameters
- $property : string
-
Object property to be unset.
Return values
$thisdoSerialize()
protected
doSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>doUnserialize()
protected
doUnserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
getElements()
protected
getElements() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getTypePrefix()
protected
getTypePrefix() : string
Return values
stringsetElements()
protected
setElements(array<string|int, mixed> $elements) : array<string|int, mixed>
Parameters
- $elements : array<string|int, mixed>