Download the PHP package brenoroosevelt/flex-fqcn-finder without Composer
On this page you can find all versions of the php package brenoroosevelt/flex-fqcn-finder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brenoroosevelt/flex-fqcn-finder
More information about brenoroosevelt/flex-fqcn-finder
Files in brenoroosevelt/flex-fqcn-finder
Package flex-fqcn-finder
Short Description Flexible FQCN Finder
License MIT
Homepage https://github.com/brenoroosevelt/flex-fqcn-finder
Informations about the package flex-fqcn-finder
Flex FQCN Finder
The Flex FQCN Finder allows you to find all the Fully Qualified Class Names (FQCN) available in a project. This package was designed to be flexible and reliable.
Features
- Find classes, traits and interfaces (PSR-4 complaint);
- Search in directories (recursively or not);
- Many filter options;
- Cache (PSR-16 complaint).
- Composite finders.
- Get classes from Composer ClassMap.
Requirements
- The following versions of PHP are supported:
^8
. - For PHP 7.*, please install version 1.0.0
Install
Usage
Use the FlexFqcnFinder\Fqcn
helper to apply filters, decorators and compositions on your own way.
Finders
Finders are classes that implement interface FqcnFinderInterface
and return a list (array) of FQCNs found.
This package provides some finders:
FlexFqcnFinder\Finder\FqcnFinder
(find classes, traits and interfaces in a directory)FlexFqcnFinder\Finder\ComposerClassMap
(from Composer autoload classes)FlexFqcnFinder\Finder\GetDeclaredClasses
(fromget_declared_classes()
)FlexFqcnFinder\Finder\GetDeclaredInterfaces
(fromget_declared_interfaces()
)FlexFqcnFinder\Finder\GetDeclaredTraits
(fromget_declared_traits()
)
Composite
You can compose finders using the FlexFqcnFinder\FqcnFinderComposite
:
Decorators
Decorators available for Finders:
FlexFqcnFinder\Finder\Decorator\CachedFqcnFinder
FlexFqcnFinder\Finder\Decorator\FilteringFqcnFinder
You can decorate any finder (including compositions):
Filters
Filters can be used as a Decorator for Finders and using it is optional.
All filters have been designed according to the Specification Pattern. You can chain the following filters using Filter::by()
or Filter::anyOf()
:
apply(Closure $fn)
belongsToNamespace(string $namespace)
classNameEndsWith(string $value)
classNameStartsWith(string $value)
hasMethod(string $method)
implementsInterface(string $interface)
isAbstract()
isClass()
isCloneable()
isFinal()
isInstanceOf(string $subject)
isInstantiable()
isInterface()
isInternal()
isIterateable()
isSubClassOf(string $class)
isTrait()
isUserDefined()
namespaceEqualsTo(string $namespace)
not(FqcnSpecification $specification)
useTrait(string $trait)
anyOf(FqcnSpecification ...$specifications)
allOf(FqcnSpecification ...$specifications)
and(FqcnSpecification ...$specifications)
or(FqcnSpecification ...$specifications)
Any filter can be used with FlexFqcnFinder\Finder\Decorator\FilteringFqcnFinder
decorator:
Creating Filters
You can create you own filter implementing interface FqcnSpecification
:
So just use it:
Contributing
Please read the Contributing guide to learn about contributing to this project.
License
This project is licensed under the terms of the MIT license. See the LICENSE file for license rights and limitations.