function UnicodeString::startsWith
Overrides AbstractString::startsWith
File
-
vendor/
symfony/ string/ UnicodeString.php, line 343
Class
- UnicodeString
- Represents a string of Unicode grapheme clusters encoded as UTF-8.
Namespace
Symfony\Component\StringCode
public function startsWith(string|iterable|AbstractString $prefix) : bool {
if ($prefix instanceof AbstractString) {
$prefix = $prefix->string;
}
elseif (!\is_string($prefix)) {
return parent::startsWith($prefix);
}
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
normalizer_is_normalized($prefix, $form) ?: ($prefix = normalizer_normalize($prefix, $form));
if ('' === $prefix || false === $prefix) {
return false;
}
if ($this->ignoreCase) {
return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8');
}
return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES);
}