scheb/implementation-iterator

Iterates a PSR-4 compliant directory for implementations of a class/interface

v1.0.0 2015-03-22 10:52 UTC

README

This library creates an iterator for a PSR-4 compliant folder structure and searches it for all implementations/extensions of an interface/class. Abstract implementations and the class itself will be ignored.

Build Status HHVM Status Coverage Status Latest Stable Version License

Usage

$iterator = new \Scheb\ImplementationIterator("src/", "Root\Namespace", "Some\Class\Or\Interface");
foreach ($iterator as $className) {
    echo $className . "\n";
}

Will return something like:

Root\Namespace\Foo\Implementation
Root\Namespace\Bar\OtherImplementation
...

Alternatively you can also have an iterator, which returns ReflectionClass instances instead of the class name:

$iterator = new \Scheb\ImplementationReflectionIterator("src/", "Root\Namespace", "Some\Class\Or\Interface");
foreach ($iterator as $reflection) {
    echo $reflection->getName() . "\n";
}

License

This library is available under the MIT license.