major update

This commit is contained in:
2026-03-04 15:56:58 +01:00
parent 16759a2732
commit 8f4dd5840d
478 changed files with 24313 additions and 8201 deletions

View File

@@ -148,4 +148,50 @@ class RepoQuery
sort($ids, SORT_NUMERIC);
return $ids;
}
public static function normalizeStringList(mixed $value, int $max = 200, ?callable $sanitizer = null): array
{
if ($max <= 0) {
return [];
}
if (is_string($value)) {
$value = array_filter(array_map('trim', explode(',', $value)));
} elseif (!is_array($value)) {
return [];
}
$flat = [];
array_walk_recursive($value, static function ($item) use (&$flat): void {
$flat[] = $item;
});
$items = [];
$seen = [];
foreach ($flat as $item) {
$text = trim((string) $item);
if ($text === '') {
continue;
}
if ($sanitizer !== null) {
$text = trim((string) $sanitizer($text));
if ($text === '') {
continue;
}
}
if (isset($seen[$text])) {
continue;
}
$seen[$text] = true;
$items[] = $text;
if (count($items) >= $max) {
break;
}
}
return $items;
}
}