public function Console::centerText in Site Audit 8.3
Take text and center it horizontally in the console.
1 call to Console::centerText()
- Console::render in src/
Renderer/ Console.php
File
- src/
Renderer/ Console.php, line 92
Class
Namespace
Drupal\site_audit\RendererCode
public function centerText(string $text) {
$width = (new Terminal())
->getWidth();
$strlen = $this->formatter
->strlenWithoutDecoration($this->output
->getFormatter(), $text);
$spaceCount = ($width - $strlen) / 2;
for ($i = 0; $i < $spaceCount; $i++) {
$text = ' ' . $text;
}
$this->output
->writeln($text);
}