Elgg  Version 6.0
Public Member Functions | List of all members
Elgg\Collections\CollectionInterface Interface Reference

An interface for organizing items into collections. More...

Inheritance diagram for Elgg\Collections\CollectionInterface:
Elgg\Collections\Collection Elgg\Menu\MenuItems Elgg\Menu\PreparedMenu Elgg\Menu\MenuSection

Public Member Functions

 all ()
 Returns all collection items by reference. More...
 
 count ()
 Count collection items. More...
 
 add ($item)
 Add a new item to collection. More...
 
 get ($id)
 Get an item by its ID. More...
 
 has ($id)
 Check if collection has an item with a given ID. More...
 
 remove ($id)
 Remove item from collection by its ID. More...
 
 fill ($items)
 Replace collection items. More...
 
 merge ($items)
 Add new items to collection, replacing items with matching IDs. More...
 
 filter (callable $callback=null)
 Filter collection items using a custom filter Returns a new collection instance. More...
 
 sort (callable $callback=null)
 Sort fields using custom callable If not provided, will sort items by priority. More...
 
 walk (callable $callback)
 Walk through members of the collection and apply a callback. More...
 
 map (callable $callback)
 Walk through all items in the collection and apply a callback. More...
 

Detailed Description

An interface for organizing items into collections.

Definition at line 8 of file CollectionInterface.php.

Member Function Documentation

Elgg\Collections\CollectionInterface::add (   $item)

Add a new item to collection.

Parameters
CollectionItemInterface$itemItem
Returns
static

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::all ( )

Returns all collection items by reference.

Returns
CollectionItemInterface[]

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::count ( )

Count collection items.

Returns
int

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::fill (   $items)

Replace collection items.

Parameters
CollectionItemInterface[]|Collection$items Items
Returns
static

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::filter ( callable  $callback = null)

Filter collection items using a custom filter Returns a new collection instance.

Parameters
callable$callbackFilter
Returns
static

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::get (   $id)

Get an item by its ID.

Parameters
string | int$idID
Returns
CollectionItemInterface|null

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::has (   $id)

Check if collection has an item with a given ID.

Parameters
string | int$idID
Returns
bool

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::map ( callable  $callback)

Walk through all items in the collection and apply a callback.

Parameters
callable$callbackMapper
Returns
mixed

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::merge (   $items)

Add new items to collection, replacing items with matching IDs.

Parameters
CollectionItemInterface[]|Collection$items Items
Returns
static

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::remove (   $id)

Remove item from collection by its ID.

Parameters
string | int$idID
Returns
static

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::sort ( callable  $callback = null)

Sort fields using custom callable If not provided, will sort items by priority.

Parameters
callable$callbackSorter
Returns
static

Implemented in Elgg\Collections\Collection.

Elgg\Collections\CollectionInterface::walk ( callable  $callback)

Walk through members of the collection and apply a callback.

Unlike CollectionInterface::map(), this method does not return the result of mapping, rather returns the exact same instance of the collection after walking through its members by reference

See also
CollectionInterface::map()
Parameters
callable$callbackCallback function
Returns
static

Implemented in Elgg\Collections\Collection.


The documentation for this interface was generated from the following file: