/**
* Create a map for a given path
*
* @param array $paths
* @return array
*/
public function createMap(...$paths)
{
$classes = [];
$this->finder->files()->ignoreUnreadableDirs()->in($paths);
foreach ($this->excludePathPatterns as $exclude) {
$this->finder->notPath($exclude);
}
foreach ($this->inPathPatterns as $inPath) {
$this->finder->path($inPath);
}
foreach ($this->names as $name) {
$this->finder->name($name);
}
/** @var SplFileInfo $file */
foreach ($this->finder as $file) {
$content = file_get_contents($file->getPathname());
preg_match('^\\s*class ([\\S]*)\\s*(extends|implements|{)^', $content, $match, PREG_OFFSET_CAPTURE);
if (isset($match[1])) {
$className = '\\' . trim($match[1][0]);
$offset = $match[1][1];
} else {
continue;
}
preg_match('|\\s*namespace\\s*([\\S]*)\\s*;|', substr($content, 0, $offset), $match);
if (isset($match[1]) && trim($match[1]) !== '') {
$className = '\\' . trim($match[1]) . $className;
}
if ($className !== '\\') {
$classes[$file->getPathname()] = $className;
}
}
return $classes;
}