protected function derivePackageKey($composerName, $packageType = null, $packagePath = null, $autoloadNamespace = null)
{
$packageKey = '';
if ($packageType !== null && ComposerUtility::isFlowPackageType($packageType)) {
$lastSegmentOfPackagePath = substr(trim($packagePath, '/'), strrpos(trim($packagePath, '/'), '/') + 1);
if (strpos($lastSegmentOfPackagePath, '.') !== false) {
$packageKey = $lastSegmentOfPackagePath;
}
}
if ($autoloadNamespace !== null && ($packageKey === null || $this->isPackageKeyValid($packageKey) === false)) {
$packageKey = str_replace('\\', '.', $autoloadNamespace);
}
if ($packageKey === null || $this->isPackageKeyValid($packageKey) === false) {
$packageKey = str_replace('/', '.', $composerName);
}
$packageKey = trim($packageKey, '.');
$packageKey = preg_replace('/[^A-Za-z0-9.]/', '', $packageKey);
return $packageKey;
}