alcamo / iterator
Iterator-related stuff
Installs: 2
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/alcamo/iterator
Requires
- php: 7.3 - 8.0
- alcamo/exception: ^0.1
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: 3.*
This package is auto-updated.
Last update: 2025-10-24 15:44:24 UTC
README
use alcamo\iterator\InputStreamLineIterator;
$iterator = new InputStreamLineIterator(fopen(__FILE__, 'r'));
foreach ($iterator as $line => $data) {
printf("%3d %s\n", $line, $data);
}
This will output its own source file with line numbers.
Provided classes and traits
IteratorCurrentTraitprovides a partial implementation of theIteratorinterface so that a class using this trait just needs to implement the methodsrewind()andnext().InputStreamLineIteratoris an iterator class that reads lines from an input stream. Flags can be given e.g. to skip empty lines. Derived classes can easily add other features such as skipping comment lines.