2017 © Pedro Peláez
 

library class-finder

Utility class to help you discover other classes / namespaces based on the composer auto loader.

image

gears/class-finder

Utility class to help you discover other classes / namespaces based on the composer auto loader.

  • Wednesday, March 28, 2018
  • by brad-jones
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,401 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 3 Open issues
  • 4 Versions
  • 184 % Grown

The README.md

Looking for maintainers, I no longer do much if any PHP dev, I have moved on, mostly work in dotnet core, node.js & golang these days. If anyone is keen to take over these projects, get in touch - brad@bjc.id.au, (*1)

Class Finder, like Symfony\Finder but for classes.

Build Status Latest Stable Version Total Downloads License Coverage Status Scrutinizer Code Quality, (*2)

Utility class to help you discover other classes / namespaces based on the composer auto loader., (*3)

How to Install

Installation via composer is easy:, (*4)

composer require gears/class-finder

Examples

// Make sure you grab the composer ClassLoader instance, the class finder needs it.
$composer = require('vendor/autoload.php');

// Create a new finder. You may reuse this as much as you like.
// Right now caching is not performed but could be in the future.
$finder = new Gears\ClassFinder($composer);

// Find all classes inside a namespace
$classes = $finder->namespace('Foo\\Bar')->search();

// Returns an array like:
$classes =
[
    '/home/user/project/vendor/foo/src/Bar/Baz.php' => 'Foo\\Bar\\Baz',
    '/home/user/project/vendor/foo/src/Bar/Qux.php' => 'Foo\\Bar\\Qux',
    'etc...'
];

// Find all classes inside a namespace that implement an interface.
$classes = $finder->namespace('Foo\\Bar')->implements('SomeInterface')->search();

// OR you can use the PHP 5.5 ::class operator
$classes = $finder->namespace('Foo\\Bar')->implements(SomeInterface::class)->search();

// Or filter by parent classes
$classes = $finder->namespace('Foo\\Bar')->extends(SomeParent::class)->search();

// NOTE: You can't do both out of the box.
$classes = $finder->namespace('Foo\\Bar')

// This is now allowed!
->implements(SomeInterface::class)
->extends(SomeParent::class)

->search();

// Although you could supply your own custom filter that implemented whatever filtering you like.
$classes = $finder->namespace('Foo\\Bar')->filterBy(function($rClass ReflectionClass)
{

    /* custom logic goes here, must return true or false */

})->search();

// ClassFinder also implements the IteratorAggregate & Countable interfaces.
$number = $finder->namespace('Foo\\Bar')->count();

foreach ($finder->namespace('Foo\\Bar') as $filepath => $fqcn)
{

}

Developed by Brad Jones - brad@bjc.id.au, (*5)

The Versions

28/03 2018

dev-master

9999999-dev https://github.com/phpgearbox/class-finder

Utility class to help you discover other classes / namespaces based on the composer auto loader.

  Sources   Download

MIT

The Requires

 

The Development Requires

reflection class finder discover

28/03 2018

v1.0.2

1.0.2.0 https://github.com/phpgearbox/class-finder

Utility class to help you discover other classes / namespaces based on the composer auto loader.

  Sources   Download

MIT

The Requires

 

The Development Requires

reflection class finder discover

10/03 2017

v1.0.1

1.0.1.0 https://github.com/phpgearbox/class-finder

Utility class to help you discover other classes / namespaces based on the composer auto loader.

  Sources   Download

MIT

The Requires

 

The Development Requires

reflection class finder discover

27/02 2017

v1.0.0

1.0.0.0 https://github.com/phpgearbox/class-finder

Utility class to help you discover other classes / namespaces based on the composer auto loader.

  Sources   Download

MIT

The Requires

 

The Development Requires

reflection class finder discover