fyre / iterator
An iterator library.
v5.0.1
2024-10-30 11:22 UTC
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^11
README
FyreIterator is a free, open-source iteration library for PHP.
Table Of Contents
Installation
Using Composer
composer require fyre/iterator
In PHP:
use Fyre\Utility\Iterator;
Basic Usage
$iterator = new Iterator();
Methods
Add
Add a test
$name
is a string representing the test name.$callback
is the callback to execute.
$iterator->add($name, $callback);
All
Get all tests.
$tests = $iterator->all();
Clear
Clear all tests.
$iterator->clear();
Count
Get the number of tests.
$count = $iterator->count();
Get
Get a specific test callback.
$name
is a string representing the test name.
$test = $iterator->get($name);
Has
Determine whether a test exists.
$name
is a string representing the test name.
$hasTest = $iterator->has($name);
Remove
Remove a test.
$name
is a string representing the test name.
$iterator->remove($name);
Run
Run the tests and return the results.
$iterations
is a number representing the number of iterations to run, and will default to 1000.
$results = $iterator->run($iterations);