scheb / implementation-iterator
Iterates a PSR-4 compliant directory for implementations of a class/interface
Installs: 11 023
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- satooshi/php-coveralls: ~0.6
This package is auto-updated.
Last update: 2022-01-11 13:25:26 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.
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.