You can add data cells with {@link addCell()}. Optionally, you can set the minimum and maximum allowed number of columns with {@link setMinNbColumns()} and {@link setMaxNbColumns()}. If you want to style the grid, pass a {@link GridStyle} to the constructor.
Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: implements Webmozart\Console\UI\Component
Exemple #1
0
 /**
  * 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);
 }
Exemple #2
0
    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());
    }