diff --git a/module/GeebyDeebyLocal/src/GeebyDeebyLocal/Ingest/ModsExtractor.php b/module/GeebyDeebyLocal/src/GeebyDeebyLocal/Ingest/ModsExtractor.php index 13c8cbcd..c347d7fb 100644 --- a/module/GeebyDeebyLocal/src/GeebyDeebyLocal/Ingest/ModsExtractor.php +++ b/module/GeebyDeebyLocal/src/GeebyDeebyLocal/Ingest/ModsExtractor.php @@ -161,6 +161,20 @@ protected function extractSeries($series) return empty($seriesInfo) ? false : $seriesInfo; } + /** + * Is a "First Last" name equivalent to a "Last, Name" name? + * + * @param string $name First Last name + * @param string $invertedName Last, First name + * + * @return bool + */ + protected function nameIsInvertedName(string $name, string $invertedName): bool + { + $parts = explode(', ', $invertedName, 2); + return $name === $parts[1] . ' ' . $parts[0]; + } + /** * Extract publisher information. * @@ -192,7 +206,7 @@ protected function extractPublisher($mods, $authMods = []) $authModsStr = (string)($authMods[0] ?? ''); if ( preg_match('/\(\d{4}/', $authModsStr) - || strlen($authModsStr) > strlen($parts[0]) + || (strlen($authModsStr) > strlen($parts[0]) && !$this->nameIsInvertedName($parts[0], $authModsStr)) ) { $newParts = explode(',', $authModsStr); foreach ($newParts as $i => $part) {