CollectionInterface
interface CollectionInterface implements ArrayInterface (View source)
A collection represents a group of objects, known as its elements. Some collections allow duplicate elements and others do not. Some are ordered and others unordered.
Methods
Returns a native PHP array containing all of the elements in this array object
Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)
Returns true
if this collection contains the specified element
Returns the type associated with this collection
Removes a single instance of the specified element from this collection, if it is present
Details
in ArrayInterface at line 28
void
clear()
Remove all the elements from this array object
in ArrayInterface at line 34
toArray()
Returns a native PHP array containing all of the elements in this array object
in ArrayInterface at line 41
bool
isEmpty()
Returns true
if this array object contains no elements
at line 45
bool
add(mixed $element)
Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)
Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.
If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.
at line 55
bool
contains(mixed $element)
Returns true
if this collection contains the specified element
This performs a strict type check on the value.
at line 62
string
getType()
Returns the type associated with this collection
at line 71
bool
remove(mixed $element)
Removes a single instance of the specified element from this collection, if it is present