Webmozart\Console\UI\Component\Grid::setMaxNbColumns PHP Méthode

setMaxNbColumns() public méthode

The default maximum is unlimited.
public setMaxNbColumns ( integer $maxNbColumns ) : static
$maxNbColumns integer The maximum number of columns.
Résultat static The current instance.
    public function setMaxNbColumns($maxNbColumns)
    {
        $this->minNbColumns = min($this->minNbColumns, $maxNbColumns);
        $this->maxNbColumns = $maxNbColumns;
        return $this;
    }

Usage Example

Exemple #1
0
    public function testSetMaxNbColumns()
    {
        $grid = new Grid(GridStyle::asciiBorder());
        $grid->setMaxNbColumns(3);
        $grid->addCells(array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri', '9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien', '80-902734-1-6', 'And Then There Were None', 'Agatha Christie'));
        $grid->render($this->io);
        $expected = <<<'EOF'
+---------------+--------------------------+------------------+
| 99921-58-10-7 | Divine Comedy            | Dante Alighieri  |
+---------------+--------------------------+------------------+
| 9971-5-0210-0 | A Tale of Two Cities     | Charles Dickens  |
+---------------+--------------------------+------------------+
| 960-425-059-0 | The Lord of the Rings    | J. R. R. Tolkien |
+---------------+--------------------------+------------------+
| 80-902734-1-6 | And Then There Were None | Agatha Christie  |
+---------------+--------------------------+------------------+

EOF;
        $this->assertSame($expected, $this->io->fetchOutput());
    }