/** * Prints the resources in the short style (without the "-l" option). * * @param IO $io The I/O. * @param ResourceCollection $resources The resources. */ private function listShort(IO $io, ResourceCollection $resources) { $style = GridStyle::borderless(); $style->getBorderStyle()->setLineVCChar(' '); $grid = new Grid($style); foreach ($resources as $resource) { $grid->addCell($this->formatName($resource)); } $grid->render($io); }
private function renderRows(IO $io, array $rows, array $columnLengths, $excessColumnLength, $indentation) { $alignments = array_fill(0, count($columnLengths), $this->style->getCellAlignment()); $borderStyle = $this->style->getBorderStyle(); $borderColumnLengths = array_map(function ($length) use($excessColumnLength) { return $length + $excessColumnLength; }, $columnLengths); BorderUtil::drawTopBorder($io, $borderStyle, $borderColumnLengths, $indentation); $last = count($rows) - 1; foreach ($rows as $i => $row) { BorderUtil::drawRow($io, $borderStyle, $row, $columnLengths, $alignments, $this->style->getCellFormat(), $this->style->getCellStyle(), $this->style->getPaddingChar(), $indentation); if ($i < $last) { BorderUtil::drawMiddleBorder($io, $borderStyle, $borderColumnLengths, $indentation); } } BorderUtil::drawBottomBorder($io, $borderStyle, $borderColumnLengths, $indentation); }
public function testRenderAllCellsInOneLine() { $grid = new Grid(GridStyle::asciiBorder()); $grid->addCells(array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri')); $grid->render($this->io); $expected = <<<'EOF' +---------------+---------------+-----------------+ | 99921-58-10-7 | Divine Comedy | Dante Alighieri | +---------------+---------------+-----------------+ EOF; $this->assertSame($expected, $this->io->fetchOutput()); }