class LimitIterator extends IteratorIterator (View source)

The LimitIterator class allows iteration over a limited subset of items in an Iterator.

Methods

__construct(Traversable $iterator, int $offset = 0, int $limit = -1)

Construct a LimitIterator

Iterator|null
getInnerIterator()

Get inner iterator

void
rewind()

Rewind the iterator to the specified starting offset

bool
valid()

Check whether the current element is valid

mixed
key()

Get current key

mixed
current()

Get current element

void
next()

Move the iterator forward

int
seek(int $offset)

Seek to the given position

int
getPosition()

Return the current position

Details

__construct(Traversable $iterator, int $offset = 0, int $limit = -1)

Construct a LimitIterator

Parameters

Traversable $iterator
int $offset

[optional] The offset to start at. Must be zero or greater.

int $limit

[optional] The number of items to iterate. Must be -1 or greater. -1, the default, means no limit.

Iterator|null getInnerIterator()

Get inner iterator

Return Value

Iterator|null

The inner iterator for the current entry.

void rewind()

Rewind the iterator to the specified starting offset

Return Value

void

Any returned value is ignored.

bool valid()

Check whether the current element is valid

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

mixed key()

Get current key

Return Value

mixed

TKey on success, or null on failure.

mixed current()

Get current element

Return Value

mixed

Can return any type.

void next()

Move the iterator forward

Return Value

void

Any returned value is ignored.

int seek(int $offset)

Seek to the given position

Parameters

int $offset

The position to seek to.

Return Value

int

the offset position after seeking.

int getPosition()

Return the current position

Return Value

int

The current position.