Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UnicodeString.php

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\String

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal