binDir = rtrim($binDir, '/\\'); $this->executableFinder = $executableFinder; } public static function loadWithPaths(Paths $paths, ExecutableFinder $executableFinder): self { return new self( $paths->getBinDir(), $executableFinder ); } public function locate(string $command): string { foreach ($this->suffixes as $suffix) { $cmdName = $command . $suffix; // Search executable: $executable = $this->executableFinder->find($cmdName, null, [$this->binDir]); if ($executable) { return $executable; } } throw new RuntimeException( sprintf('The executable for "%s" could not be found.', $command) ); } }