public function slug(string
$string, string
$separator = '-', string
$locale = null
): AbstractUnicodeString
{ $locale ??=
$this->defaultLocale;
$transliterator =
[];
if ($locale && ('de' ===
$locale ||
str_starts_with($locale, 'de_'
))) { // Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl)
$transliterator =
['de-ASCII'
];
} elseif (\
function_exists('transliterator_transliterate'
) &&
$locale) { $transliterator =
(array) $this->
createTransliterator($locale);
} if ($emojiTransliterator =
$this->
createEmojiTransliterator($locale)) { $transliterator[] =
$emojiTransliterator;
} if ($this->symbolsMap instanceof \Closure
) { // If the symbols map is passed as a closure, there is no need to fallback to the parent locale
// as the closure can just provide substitutions for all locales of interest.
$symbolsMap =
$this->symbolsMap;
array_unshift($transliterator,
static fn ($s) =>
$symbolsMap($s,
$locale));
}