Cecil

CollectionInterface extends BaseInterface, Countable, IteratorAggregate, ArrayAccess

Collection interface.

Table of Contents

Methods

add()  : self
Add an item or throw an exception if exists.
count()  : int
Implements Countable.
filter()  : self
Filters items using a callback function.
first()  : ItemInterface|null
Retrieves the first item.
get()  : ItemInterface
Retrieves an item or throw an exception if not exists.
getId()  : string
Returns the collection's identifier.
getIterator()  : ArrayIterator
Implements \IteratorAggregate.
getPosition()  : int
Retrieves an item position or throw an exception if not exists.
has()  : bool
Does the item $id exists?
keys()  : array<string|int, mixed>
Retrieves all keys.
map()  : self
Applies a callback to items.
remove()  : self
Removes an item or throw an exception if not exists.
replace()  : self
Replaces an item or throw an exception if not exists.
reverse()  : self
Reverse items order.
setId()  : BaseInterface
Set the collection's identifier.
toArray()  : array<string|int, mixed>
Returns collection as array.
toJson()  : string
Returns a JSON string of items.
usort()  : self
Implements usort.

Methods

filter()

Filters items using a callback function.

public filter(Closure $callback) : self
Parameters
$callback : Closure
Return values
self

getId()

Returns the collection's identifier.

public getId() : string
Return values
string

getIterator()

Implements \IteratorAggregate.

public getIterator() : ArrayIterator
Return values
ArrayIterator

getPosition()

Retrieves an item position or throw an exception if not exists.

public getPosition(string $id) : int
Parameters
$id : string
Return values
int

has()

Does the item $id exists?

public has(string $id) : bool
Parameters
$id : string
Return values
bool

keys()

Retrieves all keys.

public keys() : array<string|int, mixed>
Return values
array<string|int, mixed>

map()

Applies a callback to items.

public map(Closure $callback) : self
Parameters
$callback : Closure
Return values
self

remove()

Removes an item or throw an exception if not exists.

public remove(string $id) : self
Parameters
$id : string
Return values
self

toArray()

Returns collection as array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

toJson()

Returns a JSON string of items.

public toJson() : string
Return values
string

usort()

Implements usort.

public usort([Closure|null $callback = null ]) : self
Parameters
$callback : Closure|null = null
Return values
self
 
On this page

Search results