PHP Класс Ouzo\Utilities\Iterator\FluentIterator

Наследование: extends ForwardingIterator
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Описание методов

batch() публичный Метод

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

cycle() публичный Метод

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

filter() публичный Метод

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

first() публичный Метод

Returns the first element in iterator or throws an Exception if iterator is empty
public first ( ) : mixed
Результат mixed

firstOr() публичный Метод

Returns the first element in this iterator or defaultValue.
public firstOr ( $default ) : mixed
$default
Результат mixed

from() публичный статический Метод

Returns a fluent iterator that wraps $iterator
public static from ( $iterator ) : FluentIterator
$iterator
Результат FluentIterator

fromArray() публичный статический Метод

Returns a fluent iterator for $array
public static fromArray ( array $array ) : FluentIterator
$array array
Результат FluentIterator

fromFunction() публичный статический Метод

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
Результат FluentIterator

limit() публичный Метод

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

map() публичный Метод

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

reindex() публичный Метод

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

skip() публичный Метод

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

toArray() публичный Метод

Copies elements of this fluent iterator into an array.
public toArray ( ) : array
Результат array