public function center($width = 80, $text = null)
{
if ($text === null) {
$text = $this->wrapped;
}
$centered = '';
foreach (explode(PHP_EOL, $text) as $line) {
$line = trim($line);
$lineWidth = strlen($line) - mb_strlen($line, 'UTF-8') + $width;
$centered .= str_pad($line, $lineWidth, ' ', STR_PAD_BOTH) . PHP_EOL;
}
$this->setInternalState(trim($centered, PHP_EOL));
return $this;
}