You are here

class ClassShortener in Devel 8

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Helper/ClassShortener.php \Drupal\webprofiler\Helper\ClassShortener
  2. 8.2 webprofiler/src/Helper/ClassShortener.php \Drupal\webprofiler\Helper\ClassShortener
  3. 4.x webprofiler/src/Helper/ClassShortener.php \Drupal\webprofiler\Helper\ClassShortener

Class ClassShortener

Hierarchy

Expanded class hierarchy of ClassShortener

1 string reference to 'ClassShortener'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses ClassShortener
webprofiler.class_shortener in webprofiler/webprofiler.services.yml
Drupal\webprofiler\Helper\ClassShortener

File

webprofiler/src/Helper/ClassShortener.php, line 10

Namespace

Drupal\webprofiler\Helper
View source
class ClassShortener implements ClassShortenerInterface {

  /**
   * {@inheritdoc}
   */
  public function shortenClass($class) {
    $parts = explode('\\', $class);
    $result = [];
    $size = count($parts) - 1;
    foreach ($parts as $key => $part) {
      if ($key < $size) {
        $result[] = substr($part, 0, 1);
      }
      else {
        $result[] = $part;
      }
    }
    return new FormattableMarkup("<abbr title=\"@class\">@short</abbr>", [
      '@class' => $class,
      '@short' => implode('\\', $result),
    ]);
  }

}

Members