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

Breadcrumb

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

function AbstractString::trimPrefix

Parameters

string|string[] $prefix:

2 calls to AbstractString::trimPrefix()
AbstractUnicodeString::trimPrefix in vendor/symfony/string/AbstractUnicodeString.php
AbstractUnicodeString::trimPrefix in vendor/symfony/string/AbstractUnicodeString.php
1 method overrides AbstractString::trimPrefix()
AbstractUnicodeString::trimPrefix in vendor/symfony/string/AbstractUnicodeString.php

File

vendor/symfony/string/AbstractString.php, line 550

Class

AbstractString
Represents a string of abstract characters.

Namespace

Symfony\Component\String

Code

public function trimPrefix($prefix) : static {
    if (\is_array($prefix) || $prefix instanceof \Traversable) {
        // don't use is_iterable(), it's slow
        foreach ($prefix as $s) {
            $t = $this->trimPrefix($s);
            if ($t->string !== $this->string) {
                return $t;
            }
        }
        return clone $this;
    }
    $str = clone $this;
    if ($prefix instanceof self) {
        $prefix = $prefix->string;
    }
    else {
        $prefix = (string) $prefix;
    }
    if ('' !== $prefix && \strlen($this->string) >= \strlen($prefix) && 0 === substr_compare($this->string, $prefix, 0, \strlen($prefix), $this->ignoreCase)) {
        $str->string = substr($this->string, \strlen($prefix));
    }
    return $str;
}

API Navigation

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