PHP Interface Collections\CollectionInterface

Inheritance: extends collections\ConstCollectionInterface, extends collections\OutputCollectionInterface
Show file Open project: danielgsims/php-collections

Public Methods

Method Description
add ( $item ) : collections\CollectionInterface Returns a collection with $item added.
at ( $index ) : mixed Returns the item in the collection at $index.
clear ( ) : collections\CollectionInterface Removes every item from the collection.
contains ( callable $condition ) : boolean Returns true if the collection contains any items that satisfy $condition, returns false if it contains none.
count ( ) : integer Returns the number of items in the collection.
drop ( $num ) : Collection Removes all of the items in the collection starting at index $num.
dropRight ( $num ) : Collection Removes all of the items in the collectioin between index 0 and $num.
dropWhile ( callable $condition ) : Collection Iteratively drops items in the collection that satisfy $condition until an item is encountered that does not satisfy $condition.
each ( callable $callable ) Applies the callback function $callable to each item in the collection.
every ( callable $condition ) : boolean Returns true if every item in the collection satisfies $condition, returns false if not.
filter ( callable $condition ) : collections\CollectionInterface Returns a collection that only contains the items which satisfy $condition.
find ( callable $condition ) : mixed Returns the first item in the collection that satisfies $condition, returns false if no such item exists.
findIndex ( callable $condition ) : integer Returns the index of the first item in the collection that satisfies $condition, returns -1 if no such item exists.
findLast ( callable $condition ) : mixed Returns the last item in the collection that satisfies $condition, returns false if no such item exists.
findLastIndex ( callable $condition ) : integer Returns the index of the last item in the collection that satisfies $condition, returns -1 if no such item exists.
getIterator ( ) : ArrayIterato\ArrayIterator Returns an array iterator for the collection.
getType ( ) : string Returns the type of the collection.
indexExists ( $index ) : boolean Returns true if $index is within the collection's range and returns false if it is not.
insert ( $index, $item ) Inserts $item at $index.
insertRange ( $index, array $items ) Inserts the range $items at $index.
map ( callable $callable ) : collections\CollectionInterface Returns a new instance of the collection with the callback function $callable applied to each item.
merge ( $items ) : collections\CollectionInterface Adds every member of $items to the collection.
reduce ( callable $callable, null $initial = null ) : mixed Iteratively reduces the collection to a single value using the callback function $callable.
reduceRight ( callable $callable, null $initial = null ) : mixed Iteratively reduces the collection to a single value using the callback function $callable starting at the rightmost index.
removeAt ( $index ) : collections\CollectionInterface Removes the item at $index.
reverse ( ) : collections\CollectionInterface Reverses the order of the items in the collection.
shuffle ( ) : collections\CollectionInterface Randomly reorders the items in the collection.
slice ( $start, $end ) : collections\CollectionInterface Returns a collection that contains the subset of items ranging from the index $start to $end.
sort ( callable $callback ) : collections\CollectionInterface Sorts the items in the collection using the user supplied comparison function $callback.
tail ( ) : Collection Removes the first item in the collection.
take ( $num ) : Collection Removes all of the items in the collection starting at index $num.
takeRight ( $num ) : Collection Removes all of the items in the collection before index $num.
takeWhile ( callable $condition ) : Collection Iterates through the collection until an item is encountered that does not satisfy $condition, then drops all of the items starting at that index.
toArray ( ) : array Returns an array containing the items in the collection.
without ( callable $condition ) : Collection Removes all of the items that satisfy $condition.

Method Details

add() public method

Returns a collection with $item added.
public add ( $item ) : collections\CollectionInterface
$item
return collections\CollectionInterface

at() public method

Returns the item in the collection at $index.
public at ( $index ) : mixed
$index
return mixed

clear() public method

Removes every item from the collection.
public clear ( ) : collections\CollectionInterface
return collections\CollectionInterface

contains() public method

Returns true if the collection contains any items that satisfy $condition, returns false if it contains none.
public contains ( callable $condition ) : boolean
$condition callable
return boolean

count() public method

Returns the number of items in the collection.
public count ( ) : integer
return integer

drop() public method

Removes all of the items in the collection starting at index $num.
public drop ( $num ) : Collection
$num
return Collection

dropRight() public method

Removes all of the items in the collectioin between index 0 and $num.
public dropRight ( $num ) : Collection
$num
return Collection

dropWhile() public method

Iteratively drops items in the collection that satisfy $condition until an item is encountered that does not satisfy $condition.
public dropWhile ( callable $condition ) : Collection
$condition callable
return Collection

each() public method

Applies the callback function $callable to each item in the collection.
public each ( callable $callable )
$callable callable

every() public method

Returns true if every item in the collection satisfies $condition, returns false if not.
public every ( callable $condition ) : boolean
$condition callable
return boolean

filter() public method

Returns a collection that only contains the items which satisfy $condition.
public filter ( callable $condition ) : collections\CollectionInterface
$condition callable
return collections\CollectionInterface

find() public method

Returns the first item in the collection that satisfies $condition, returns false if no such item exists.
public find ( callable $condition ) : mixed
$condition callable
return mixed

findIndex() public method

Returns the index of the first item in the collection that satisfies $condition, returns -1 if no such item exists.
public findIndex ( callable $condition ) : integer
$condition callable
return integer

findLast() public method

Returns the last item in the collection that satisfies $condition, returns false if no such item exists.
public findLast ( callable $condition ) : mixed
$condition callable
return mixed

findLastIndex() public method

Returns the index of the last item in the collection that satisfies $condition, returns -1 if no such item exists.
public findLastIndex ( callable $condition ) : integer
$condition callable
return integer

getIterator() public method

Returns an array iterator for the collection.
public getIterator ( ) : ArrayIterato\ArrayIterator
return ArrayIterato\ArrayIterator

getType() public method

Returns the type of the collection.
public getType ( ) : string
return string

indexExists() public method

Returns true if $index is within the collection's range and returns false if it is not.
public indexExists ( $index ) : boolean
$index
return boolean

insert() public method

Inserts $item at $index.
public insert ( $index, $item )
$index
$item

insertRange() public method

Inserts the range $items at $index.
public insertRange ( $index, array $items )
$index
$items array

map() public method

Returns a new instance of the collection with the callback function $callable applied to each item.
public map ( callable $callable ) : collections\CollectionInterface
$callable callable
return collections\CollectionInterface

merge() public method

Adds every member of $items to the collection.
public merge ( $items ) : collections\CollectionInterface
$items
return collections\CollectionInterface

reduce() public method

Iteratively reduces the collection to a single value using the callback function $callable.
public reduce ( callable $callable, null $initial = null ) : mixed
$callable callable
$initial null
return mixed

reduceRight() public method

Iteratively reduces the collection to a single value using the callback function $callable starting at the rightmost index.
public reduceRight ( callable $callable, null $initial = null ) : mixed
$callable callable
$initial null
return mixed

removeAt() public method

Removes the item at $index.
public removeAt ( $index ) : collections\CollectionInterface
$index
return collections\CollectionInterface

reverse() public method

Reverses the order of the items in the collection.
public reverse ( ) : collections\CollectionInterface
return collections\CollectionInterface

shuffle() public method

Randomly reorders the items in the collection.
public shuffle ( ) : collections\CollectionInterface
return collections\CollectionInterface

slice() public method

Returns a collection that contains the subset of items ranging from the index $start to $end.
public slice ( $start, $end ) : collections\CollectionInterface
$start
$end
return collections\CollectionInterface

sort() public method

Sorts the items in the collection using the user supplied comparison function $callback.
public sort ( callable $callback ) : collections\CollectionInterface
$callback callable
return collections\CollectionInterface

tail() public method

Removes the first item in the collection.
public tail ( ) : Collection
return Collection

take() public method

Removes all of the items in the collection starting at index $num.
public take ( $num ) : Collection
$num
return Collection

takeRight() public method

Removes all of the items in the collection before index $num.
public takeRight ( $num ) : Collection
$num
return Collection

takeWhile() public method

Iterates through the collection until an item is encountered that does not satisfy $condition, then drops all of the items starting at that index.
public takeWhile ( callable $condition ) : Collection
$condition callable
return Collection

toArray() public method

Returns an array containing the items in the collection.
public toArray ( ) : array
return array

without() public method

Removes all of the items that satisfy $condition.
public without ( callable $condition ) : Collection
$condition callable
return Collection