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

Breadcrumb

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

function AbstractString::trimSuffix

Parameters

string|string[] $suffix:

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

File

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

Class

AbstractString
Represents a string of abstract characters.

Namespace

Symfony\Component\String

Code

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

API Navigation

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