if (!
$rule =
array_shift($rules)) { $rules =
[]; // An empty rule interrupts the next ones
} if ($rule instanceof \Transliterator
) { $s =
$rule->
transliterate($s);
} elseif ($rule instanceof \Closure
) { $s =
$rule($s);
} elseif ($rule) { if ('nfd' ===
$rule =
strtolower($rule)) { normalizer_is_normalized($s, self::NFD
) ?:
$s =
normalizer_normalize($s, self::NFD
);
} elseif ('nfkd' ===
$rule) { normalizer_is_normalized($s, self::NFKD
) ?:
$s =
normalizer_normalize($s, self::NFKD
);
} elseif ('[:nonspacing mark:] remove' ===
$rule) { $s =
preg_replace('/\p{Mn}++/u', '',
$s);
} elseif ('latin-ascii' ===
$rule) { $s =
str_replace(self::TRANSLIT_FROM, self::TRANSLIT_TO,
$s);
} elseif ('de-ascii' ===
$rule) { $s =
preg_replace("/([AUO])\u{0308}(?=\p{Ll})/u", '$1e',
$s);
$s =
str_replace(["a\u{0308}", "o\u{0308}", "u\u{0308}", "A\u{0308}", "O\u{0308}", "U\u{0308}"
],
['ae', 'oe', 'ue', 'AE', 'OE', 'UE'
],
$s);
} elseif (\
function_exists('transliterator_transliterate'
)) { if (null ===
$transliterator = self::
$transliterators[$rule] ??= \Transliterator::
create($rule)) {