private function getRelatedFiles(FileInterface $file)
{
// Match foo(_local).*(.dist)
$base = $file->getFilename();
if (Str::endsWith($base, '.dist')) {
$base = substr($base, 0, -5);
}
$ext = pathinfo($base, PATHINFO_EXTENSION);
$base = Str::replaceLast(".{$ext}", '', $base);
$base = Str::replaceLast('_local', '', $base);
$dir = $file->getParent();
$related = [];
foreach ([".{$ext}", "_local.{$ext}", ".{$ext}.dist"] as $tail) {
$f = $dir->getFile($base . $tail);
if ($f->getFilename() !== $file->getFilename() && $f->exists()) {
$related[] = $f;
}
}
return $related;
}