-
-
Notifications
You must be signed in to change notification settings - Fork 0
TrimIteratorIterator
github-actions edited this page Mar 31, 2026
·
4 revisions
Class TrimIteratorIterator.
An iterator that trims each value within a Traversable.
This class extends ClosureIteratorIterator and applies trim()
to each element, removing leading and trailing characters based on
the specified character mask.
- Full name:
\FastForward\Iterator\TrimIteratorIterator - Parent class:
\FastForward\Iterator\ClosureIteratorIterator
Initializes the TrimIteratorIterator.
public __construct(iterable $iterator, string|null $characters = \self::DEFAULT_CHARACTERS): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$iterator |
iterable | the iterator containing values to be trimmed |
$characters |
string|null | A string defining the characters to be trimmed. |
| Defaults to standard whitespace characters. |
Counts the number of elements in the iterable.
public count(): intIf the inner iterator implements Countable, it uses that. Otherwise, it counts the elements by iterating through them.
Return Value:
the number of elements in the iterable
Initializes the ClosureIteratorIterator.
public __construct(iterable $iterator, \Closure $closure): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$iterator |
iterable | the underlying iterator to wrap |
$closure |
\Closure | the transformation function applied to each element |
Returns the current transformed element.
public current(): mixedThe closure is applied to the original current element of the iterator.
Return Value:
the transformed element