public function ClassShortener::shortenClass in Devel 4.x
Same name and namespace in other branches
- 8.3 webprofiler/src/Helper/ClassShortener.php \Drupal\webprofiler\Helper\ClassShortener::shortenClass()
- 8 webprofiler/src/Helper/ClassShortener.php \Drupal\webprofiler\Helper\ClassShortener::shortenClass()
- 8.2 webprofiler/src/Helper/ClassShortener.php \Drupal\webprofiler\Helper\ClassShortener::shortenClass()
Parameters
string $class:
Return value
string
Overrides ClassShortenerInterface::shortenClass
File
- webprofiler/
src/ Helper/ ClassShortener.php, line 15
Class
- ClassShortener
- Class ClassShortener.
Namespace
Drupal\webprofiler\HelperCode
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),
]);
}