chain = Collection::create($discovery) // Create a discovery class for the dicovery type ->map(function ($discoveryClass) use ($projectDirectory) { return new $discoveryClass($projectDirectory); }) // Use only those where we can locate a corresponding config file ->filter(function ($discovery) { return $discovery->locate(); }); } /** * {@inheritDoc} */ public function locate() { return $this->chain->count() > 0; } /** * {@inheritDoc} */ public function discoveryExists($name) { return $this->chain->offsetExists($name); } }