\Charcoal\ModelCollectionInterface

Defines a model collection.

Summary

Methods
Constants
merge()
add()
get()
has()
remove()
clear()
all()
values()
keys()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

merge()

merge(array|\Charcoal\Model\Traversable  $objs) : \Charcoal\Model\CollectionInterface

Merge the collection with the given objects.

Parameters

array|\Charcoal\Model\Traversable $objs

Array of objects to append to this collection.

Returns

\Charcoal\Model\CollectionInterface

add()

add(object  $obj) : \Charcoal\Model\CollectionInterface

Add an object to the collection.

Parameters

object $obj

An acceptable object.

Returns

\Charcoal\Model\CollectionInterface

get()

get(mixed  $key) : object|null

Retrieve the object by primary key.

Parameters

mixed $key

The primary key.

Returns

object|null —

The object or NULL if not in the collection.

has()

has(string  $key) : boolean

Determine if an object exists in the collection by key.

Parameters

string $key

The primary key to lookup.

Returns

boolean

remove()

remove(mixed  $key) : \Charcoal\Model\CollectionInterface

Remove object from collection by primary key.

Parameters

mixed $key

The object primary key to remove.

Returns

\Charcoal\Model\CollectionInterface

all()

all() : array<mixed,object>

Retrieve all objects in collection indexed by primary keys.

Returns

array<mixed,object> —

An associative array of objects.

values()

values() : array<mixed,object>

Retrieve all objects in the collection indexed numerically.

Returns

array<mixed,object> —

A sequential array of objects.

keys()

keys() : array

Retrieve the primary keys of the objects in the collection.

Returns

array —

A sequential array of keys.