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

Breadcrumb

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

function FormatterHelper::truncate

Truncates a message to the given length.

File

vendor/symfony/console/Helper/FormatterHelper.php, line 66

Class

FormatterHelper
The Formatter class provides helpers to format messages.

Namespace

Symfony\Component\Console\Helper

Code

public function truncate(string $message, int $length, string $suffix = '...') : string {
    $computedLength = $length - self::width($suffix);
    if ($computedLength > self::width($message)) {
        return $message;
    }
    return self::substr($message, 0, $length) . $suffix;
}

API Navigation

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