function UnicodeString::normalize
Overrides AbstractUnicodeString::normalize
File
-
vendor/
symfony/ string/ UnicodeString.php, line 201
Class
- UnicodeString
- Represents a string of Unicode grapheme clusters encoded as UTF-8.
Namespace
Symfony\Component\StringCode
public function normalize(int $form = self::NFC) : static {
$str = clone $this;
if (\in_array($form, [
self::NFC,
self::NFKC,
], true)) {
normalizer_is_normalized($str->string, $form) ?: ($str->string = normalizer_normalize($str->string, $form));
}
elseif (!\in_array($form, [
self::NFD,
self::NFKD,
], true)) {
throw new InvalidArgumentException('Unsupported normalization form.');
}
elseif (!normalizer_is_normalized($str->string, $form)) {
$str->string = normalizer_normalize($str->string, $form);
$str->ignoreCase = null;
}
return $str;
}