getWidth(); $rightWidth = $this->getLineWidth($this->right ?: ''); $leftWidth = $this->getLineWidth($this->left ?: ''); if (! $leftWidth) { $style->writeln($this->right); return; } $dotsCount = max($width - $rightWidth - $leftWidth - 2, 0); $style->writeln("{$this->right} ".Str::repeat('.', $dotsCount)." {$this->left}"); } private function getLineWidth(string $string) { $re = '/<.*?>/m'; return mb_strlen(preg_replace($re, '', $string)); } }