-
-
Notifications
You must be signed in to change notification settings - Fork 0
FileExtensionFilterIterator
A filter iterator that only accepts files matching specified extensions.
This iterator is designed to traverse a directory and filter files
by their extension. It supports both FilesystemIterator and RecursiveIterator.
- Full name:
\FastForward\Iterator\FileExtensionFilterIterator - Parent class:
\FastForward\Iterator\CountableFilterIterator
Initializes the FileExtensionFilterIterator.
public __construct(\FilesystemIterator|\RecursiveDirectoryIterator $iterator, string $extensions): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$iterator |
\FilesystemIterator|\RecursiveDirectoryIterator | the directory iterator to wrap |
$extensions |
string | The allowed file extensions. |
Determines whether the current file should be accepted.
public accept(): bool- Directories are accepted only if the underlying iterator is recursive.
- Files are accepted only if their extension matches the allowed list.
Return Value:
true if the file is accepted, false otherwise
Counts the number of elements exposed by the inner iterator.
public count(): intIf the inner iterator implements
-
See: \Countable, this method SHALL return the value provided by that implementation. Otherwise, it MUST count elements by iterating over the iterator. If the inner iterator is not cloneable, this method SHALL wrap the current object in an
-
See: \IteratorIterator instance and count through that wrapper to avoid performing an invalid clone operation. If the inner iterator is cloneable, this method SHOULD count over a clone so that the original iterator state is preserved as much as possible.
Return Value:
the total number of elements available from the inner iterator