function Table::renderRowSeparator
Renders horizontal header separator.
Example:
+-----+-----------+-------+
1 call to Table::renderRowSeparator()
- Table::render in vendor/
symfony/ console/ Helper/ Table.php - Renders table to output.
File
-
vendor/
symfony/ console/ Helper/ Table.php, line 465
Class
- Table
- Provides helpers to display a table.
Namespace
Symfony\Component\Console\HelperCode
private function renderRowSeparator(int $type = self::SEPARATOR_MID, ?string $title = null, ?string $titleFormat = null) : void {
if (!($count = $this->numberOfColumns)) {
return;
}
$borders = $this->style
->getBorderChars();
if (!$borders[0] && !$borders[2] && !$this->style
->getCrossingChar()) {
return;
}
$crossings = $this->style
->getCrossingChars();
if (self::SEPARATOR_MID === $type) {
[
$horizontal,
$leftChar,
$midChar,
$rightChar,
] = [
$borders[2],
$crossings[8],
$crossings[0],
$crossings[4],
];
}
elseif (self::SEPARATOR_TOP === $type) {
[
$horizontal,
$leftChar,
$midChar,
$rightChar,
] = [
$borders[0],
$crossings[1],
$crossings[2],
$crossings[3],
];
}
elseif (self::SEPARATOR_TOP_BOTTOM === $type) {
[
$horizontal,
$leftChar,
$midChar,
$rightChar,
] = [
$borders[0],
$crossings[9],
$crossings[10],
$crossings[11],
];
}
else {
[
$horizontal,
$leftChar,
$midChar,
$rightChar,
] = [
$borders[0],
$crossings[7],
$crossings[6],
$crossings[5],
];
}
$markup = $leftChar;
for ($column = 0; $column < $count; ++$column) {
$markup .= str_repeat($horizontal, $this->effectiveColumnWidths[$column]);
$markup .= $column === $count - 1 ? $rightChar : $midChar;
}
if (null !== $title) {
$titleLength = Helper::width(Helper::removeDecoration($formatter = $this->output
->getFormatter(), $formattedTitle = \sprintf($titleFormat, $title)));
$markupLength = Helper::width($markup);
if ($titleLength > ($limit = $markupLength - 4)) {
$titleLength = $limit;
$formatLength = Helper::width(Helper::removeDecoration($formatter, \sprintf($titleFormat, '')));
$formattedTitle = \sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3) . '...');
}
$titleStart = intdiv($markupLength - $titleLength, 2);
if (false === mb_detect_encoding($markup, null, true)) {
$markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength);
}
else {
$markup = mb_substr($markup, 0, $titleStart) . $formattedTitle . mb_substr($markup, $titleStart + $titleLength);
}
}
$this->output
->writeln(\sprintf($this->style
->getBorderFormat(), $markup));
}