-
-
Notifications
You must be signed in to change notification settings - Fork 0
RangeIterator
github-actions edited this page Mar 31, 2026
·
2 revisions
An iterator that behaves like PHP's range() function.
It supports both ascending and descending sequences and allows iteration over floating-point or integer ranges.
- Full name:
\FastForward\Iterator\RangeIterator - This class implements:
Iterator,Countable
Initializes the RangeIterator.
public __construct(float|int $start, float|int $end, float|int $step = 1, bool $includeBoundary = false): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$start |
float|int | the starting value of the range |
$end |
float|int | the ending value of the range |
$step |
float|int | the step size between values (must be positive) |
$includeBoundary |
bool | whether the iterator should force the end value when the next step would overshoot it |
Throws:
if step is non-positive or greater than the range size
Returns the current value in the range.
public current(): float|intReturn Value:
the current value
Returns the current key (index).
public key(): intReturn Value:
the current index in the iteration
Moves to the next value in the range.
public next(): voidResets the iterator to the start of the range.
public rewind(): voidChecks if the current position is within the valid range.
public valid(): boolReturn Value:
true if the current value is within the valid range, false otherwise
Counts the total number of steps in the range.
public count(): intReturn Value:
the number of elements in the range