*/ protected Collection $chain; /** * Optionally specify project directory; $configFile will be relative to * this value. * * @param array> $discovery */ public function __construct(array $discovery, string $projectDirectory = '') { $this->chain = (new Collection($discovery)) // Create a discovery class for the dicovery type ->map(static fn(string $discoveryClass) => new $discoveryClass($projectDirectory)) // Use only those where we can locate a corresponding config file ->filter(static fn(DiscoveryInterface $discovery) => $discovery->locate()); } /** * {@inheritDoc} */ public function locate(): bool { return $this->chain->count() > 0; } /** * {@inheritDoc} */ public function discoveryExists(string $name): bool { return $this->chain->has($name); } }