PHP Class Collections\Collection

Inheritance: implements collections\CollectionInterface, use trait TypeValidator
Mostra file Open project: danielgsims/php-collections Class Usage Examples

Protected Properties

Property Type Description
$items array The collection's encapsulated array

Public Methods

Method Description
__construct ( $type, array $items = [] ) Instantiates the collection by specifying what type of Object will be used.
add ( $item )
at ( $index )
clear ( )
contains ( callable $condition )
count ( )
drop ( $num )
dropRight ( $num )
dropWhile ( callable $condition )
each ( callable $callable )
every ( callable $condition )
filter ( callable $condition )
find ( callable $condition )
findIndex ( callable $condition )
findLast ( callable $condition )
findLastIndex ( callable $condition )
getIterator ( )
getType ( )
indexExists ( $index )
insert ( $index, $item )
insertRange ( $index, array $items )
map ( callable $callable )
merge ( $items )
reduce ( callable $callable, $initial = null )
reduceRight ( callable $callable, $initial = null )
removeAt ( $index )
reverse ( )
shuffle ( )
slice ( $start, $end )
sort ( callable $callback )
tail ( )
take ( $num )
takeRight ( $num )
takeWhile ( callable $condition )
toArray ( )
without ( callable $condition )

Protected Methods

Method Description
countWhileTrue ( callable $condition ) : integer
setItemsFromTrustedSource ( array $items )

Private Methods

Method Description
validateIndex ( integer $index ) Validates a number to be used as an index

Method Details

__construct() public method

Instantiates the collection by specifying what type of Object will be used.
public __construct ( $type, array $items = [] )
$type
$items array

add() public method

public add ( $item )

at() public method

public at ( $index )

clear() public method

public clear ( )

contains() public method

public contains ( callable $condition )
$condition callable

count() public method

public count ( )

countWhileTrue() protected method

protected countWhileTrue ( callable $condition ) : integer
$condition callable
return integer

drop() public method

public drop ( $num )

dropRight() public method

public dropRight ( $num )

dropWhile() public method

public dropWhile ( callable $condition )
$condition callable

each() public method

public each ( callable $callable )
$callable callable

every() public method

public every ( callable $condition )
$condition callable

filter() public method

public filter ( callable $condition )
$condition callable

find() public method

public find ( callable $condition )
$condition callable

findIndex() public method

public findIndex ( callable $condition )
$condition callable

findLast() public method

public findLast ( callable $condition )
$condition callable

findLastIndex() public method

public findLastIndex ( callable $condition )
$condition callable

getIterator() public method

public getIterator ( )

getType() public method

public getType ( )

indexExists() public method

public indexExists ( $index )

insert() public method

public insert ( $index, $item )

insertRange() public method

public insertRange ( $index, array $items )
$items array

map() public method

public map ( callable $callable )
$callable callable

merge() public method

public merge ( $items )

reduce() public method

public reduce ( callable $callable, $initial = null )
$callable callable

reduceRight() public method

public reduceRight ( callable $callable, $initial = null )
$callable callable

removeAt() public method

public removeAt ( $index )

reverse() public method

public reverse ( )

setItemsFromTrustedSource() protected method

protected setItemsFromTrustedSource ( array $items )
$items array

shuffle() public method

public shuffle ( )

slice() public method

public slice ( $start, $end )

sort() public method

public sort ( callable $callback )
$callback callable

tail() public method

public tail ( )

take() public method

public take ( $num )

takeRight() public method

public takeRight ( $num )

takeWhile() public method

public takeWhile ( callable $condition )
$condition callable

toArray() public method

public toArray ( )

without() public method

public without ( callable $condition )
$condition callable

Property Details

$items protected_oe property

The collection's encapsulated array
protected array $items
return array