参考文献的作者数变成6

This commit is contained in:
wangjinlei
2026-08-07 17:51:18 +08:00
parent a1e151048c
commit f87057488b
10 changed files with 386 additions and 49 deletions

View File

@@ -406,10 +406,11 @@ class PubmedService
}
/**
* 引用格式作者串:姓全写 + 名首字母,超过 $maxAuthors 个取前 N 个 + et al
* Smith JA, Jones B, Lee C, et al
* 引用格式作者串:姓全写 + 名首字母
* 著录规则:作者数 <= $maxAuthors 时全部列出,超过时只列前 $keep 个再加 et al
* 例7 个作者 → Smith JA, Jones B, Lee C, et al
*/
public function authorsCitation(array $authors, int $maxAuthors = 3): string
public function authorsCitation(array $authors, int $maxAuthors = 6, int $keep = 3): string
{
$list = [];
foreach ($authors as $a) {
@@ -435,8 +436,9 @@ class PubmedService
}
$maxAuthors = max(1, $maxAuthors);
$keep = min(max(1, $keep), $maxAuthors);
if (count($list) > $maxAuthors) {
return implode(', ', array_slice($list, 0, $maxAuthors)) . ', et al';
return implode(', ', array_slice($list, 0, $keep)) . ', et al';
}
return implode(', ', $list);
}