本文整理汇总了PHP中Symfony\Component\Console\Helper\TableStyle::setHorizontalBorderChar方法的典型用法代码示例。如果您正苦于以下问题:PHP TableStyle::setHorizontalBorderChar方法的具体用法?PHP TableStyle::setHorizontalBorderChar怎么用?PHP TableStyle::setHorizontalBorderChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\TableStyle
的用法示例。
在下文中一共展示了TableStyle::setHorizontalBorderChar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
*
* {@inheritDoc}
*
* @see \SK\ITCBundle\Service\Table\Adapter\IAdapter::write()
*/
public function write(Table $table, OutputInterface $output)
{
$style = new TableStyle();
$style->setHorizontalBorderChar('<fg=magenta>-</>')->setVerticalBorderChar('<fg=magenta>|</>')->setCrossingChar('<fg=magenta>+</>');
$stable = new STable($output);
$stable->setStyle('default');
$stable->setHeaders($table->getHeaders());
$columns = $table->getColumns();
$colspan = count($columns);
$rows = $table->getRows();
foreach ($rows as $row) {
$rowModificated = [];
foreach ($columns as $iCol => $col) {
if (is_int($iCol)) {
$iCol = $col;
}
if (array_key_exists($iCol, $row)) {
$rowModificated[$iCol] = wordwrap($row[$iCol], $table->getMaxColWidth(), "\n", true);
} else {
$rowModificated[$iCol] = "";
}
}
$stable->addRow($rowModificated);
$stable->addRow(array(new TableSeparator(array('colspan' => $colspan))));
}
$stable->addRow(array(new TableCell("", array('colspan' => $colspan))));
$stable->addRow(array(new TableCell(sprintf("Found %s results.", count($rows)), array('colspan' => $colspan))));
$stable->render();
}
示例2: initStyles
private static function initStyles()
{
$borderless = new TableStyle();
$borderless->setHorizontalBorderChar('=')->setVerticalBorderChar(' ')->setCrossingChar(' ');
$compact = new TableStyle();
$compact->setHorizontalBorderChar('')->setVerticalBorderChar(' ')->setCrossingChar('')->setCellRowContentFormat('%s');
return array('default' => new TableStyle(), 'borderless' => $borderless, 'compact' => $compact);
}
示例3: displayErrors
/**
* Display validation errors.
*
* @param Validator $validator The json-schema validator.
* @param OutputInterface $output An OutputInterface instance.
*/
public static function displayErrors(Validator $validator, OutputInterface $output)
{
$table = new Table($output);
$style = new TableStyle();
$style->setCellHeaderFormat('<error>%s</error>');
$style->setHorizontalBorderChar(' ');
$style->setVerticalBorderChar(' ');
$style->setCrossingChar(' ');
$table->setHeaders(['Property', 'Error']);
$table->setRows($validator->getErrors());
$table->setStyle($style);
$table->render();
}
示例4: table
/**
* {@inheritdoc}
*/
public function table(array $headers, array $rows)
{
$headers = array_map(function ($value) {
return sprintf("<info>%s</info>", $value);
}, $headers);
$styleGuide = new TableStyle();
$styleGuide->setHorizontalBorderChar('-')->setVerticalBorderChar('|')->setCrossingChar('+')->setCellHeaderFormat('%s');
$table = new Table($this);
$table->setHeaders($headers);
$table->setRows($rows);
$table->setStyle($styleGuide);
$table->render();
$this->newLine();
}
示例5: displayTableResults
public function displayTableResults(OutputInterface $output, $object, array $keysOnly = [], $maxWidth = 35, $count = false)
{
$table = new Table($output);
$style = new TableStyle();
$style->setHorizontalBorderChar('<fg=magenta>-</>')->setVerticalBorderChar('<fg=magenta>|</>')->setCrossingChar(' ');
$table->setStyle($style);
if ($object instanceof CollectionAbstract) {
$list = $object->toArray();
} else {
$list = $object;
}
$i = 0;
foreach ($list as $item) {
if (!is_array($item)) {
continue;
}
++$i;
foreach ($item as $key => $value) {
if (!empty($keysOnly) && !in_array($key, $keysOnly, true)) {
unset($item[$key]);
continue;
}
if (is_array($value)) {
$value = json_encode($value);
}
if (is_float($value)) {
$value = number_format($value, 3);
}
$value = str_replace(['["', '"]', '{"', '"', '}'], [], $value);
if (empty($value)) {
$value = '~';
}
$value = substr($value, 0, $maxWidth);
$item[$key] = $value;
}
if (true === $count) {
$item = array_merge(['#' => $i], $item);
}
if (!isset($headers)) {
$headers = array_keys($item);
$table->setHeaders($headers);
}
$table->addRow($item);
}
return $table->render($output);
}
示例6: testStyle
public function testStyle()
{
$style = new TableStyle();
$style->setHorizontalBorderChar('.')->setVerticalBorderChar('.')->setCrossingChar('.');
Table::setStyleDefinition('dotfull', $style);
$table = new Table($output = $this->getOutputStream());
$table->setHeaders(array('Foo'))->setRows(array(array('Bar')))->setStyle('dotfull');
$table->render();
$expected = <<<TABLE
.......
. Foo .
.......
. Bar .
.......
TABLE;
$this->assertEquals($expected, $this->getOutputContent($output));
}
示例7: addCustomTableStyles
/**
* Add our custom table style(s) to the table.
*/
protected static function addCustomTableStyles($table)
{
// The 'consolidation' style is the same as the 'symfony-style-guide'
// style, except it maintains the colored headers used in 'default'.
$consolidationStyle = new TableStyle();
$consolidationStyle->setHorizontalBorderChar('-')->setVerticalBorderChar(' ')->setCrossingChar(' ');
$table->setStyleDefinition('consolidation', $consolidationStyle);
}
示例8: table
/**
* @param string[] $rows
* @param string[] $headers
*/
public function table(array $rows, array $headers = null)
{
$rows = array_map(function ($value) {
if (!is_array($value)) {
return $value;
}
$header = array_shift($value);
array_unshift($value, sprintf('<fg=blue>%s</>', $header));
return $value;
}, $rows);
$style = new TableStyle();
$style->setVerticalBorderChar('<fg=blue>|</>');
$style->setHorizontalBorderChar('<fg=blue>-</>');
$style->setCrossingChar('<fg=blue>+</>');
$style->setCellHeaderFormat('%s');
$table = new Table($this);
$table->setStyle($style);
if ($headers) {
$table->setHeaders($headers);
}
$table->setRows($rows);
$table->render();
$this->newLine();
}