ClassShortener.php in Devel 8.3
File
webprofiler/src/Helper/ClassShortener.php
View source
<?php
namespace Drupal\webprofiler\Helper;
use Drupal\Component\Render\FormattableMarkup;
class ClassShortener implements ClassShortenerInterface {
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),
]);
}
}