PHP Class Ouzo\Utilities\Iterator\FluentIterator

Inheritance: extends ForwardingIterator
ファイルを表示 Open project: letsdrink/ouzo Class Usage Examples

Public Methods

Method Description
batch ( $chunkSize ) Returns a fluent iterator returning elements of this fluent iterator grouped in chunks of $chunkSize Returns the
cycle ( ) Returns a fluent iterator that cycles indefinitely over the elements of this fluent iterator.
filter ( $predicate ) Returns a fluent iterator returning elements of this fluent iterator that satisfy a predicate.
first ( ) : mixed Returns the first element in iterator or throws an Exception if iterator is empty
firstOr ( $default ) : mixed Returns the first element in this iterator or defaultValue.
from ( $iterator ) : FluentIterator Returns a fluent iterator that wraps $iterator
fromArray ( array $array ) : FluentIterator Returns a fluent iterator for $array
fromFunction ( $generator ) : FluentIterator Returns a fluent iterator that uses $function to generate elements $function takes one argument which is the current position of the iterator.
limit ( $number ) Returns a fluent iterator returning the first $number elements of of this fluent iterator.
map ( $function ) Returns a fluent iterator that applies function to each element of this fluent iterator.
reindex ( ) Returns an iterator that indexes elements numerically starting from 0
skip ( $number ) Returns a fluent iterator returning all but first $number elements of this fluent iterator.
toArray ( ) : array Copies elements of this fluent iterator into an array.

Method Details

batch() public method

Returns a fluent iterator returning elements of this fluent iterator grouped in chunks of $chunkSize Returns the
public batch ( $chunkSize )
$chunkSize

cycle() public method

Returns a fluent iterator that cycles indefinitely over the elements of this fluent iterator.
public cycle ( )

filter() public method

Returns a fluent iterator returning elements of this fluent iterator that satisfy a predicate.
public filter ( $predicate )
$predicate

first() public method

Returns the first element in iterator or throws an Exception if iterator is empty
public first ( ) : mixed
return mixed

firstOr() public method

Returns the first element in this iterator or defaultValue.
public firstOr ( $default ) : mixed
$default
return mixed

from() public static method

Returns a fluent iterator that wraps $iterator
public static from ( $iterator ) : FluentIterator
$iterator
return FluentIterator

fromArray() public static method

Returns a fluent iterator for $array
public static fromArray ( array $array ) : FluentIterator
$array array
return FluentIterator

fromFunction() public static method

Returns a fluent iterator that uses $function to generate elements $function takes one argument which is the current position of the iterator.
public static fromFunction ( $generator ) : FluentIterator
$generator
return FluentIterator

limit() public method

Returns a fluent iterator returning the first $number elements of of this fluent iterator.
public limit ( $number )
$number

map() public method

Returns a fluent iterator that applies function to each element of this fluent iterator.
public map ( $function )
$function

reindex() public method

Returns an iterator that indexes elements numerically starting from 0
public reindex ( )

skip() public method

Returns a fluent iterator returning all but first $number elements of this fluent iterator.
public skip ( $number )
$number

toArray() public method

Copies elements of this fluent iterator into an array.
public toArray ( ) : array
return array