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

setMinNbColumns() public méthode

The default minimum is 4.
public setMinNbColumns ( integer $minNbColumns ) : static
$minNbColumns integer The minimum number of columns.
Résultat static The current instance.
    public function setMinNbColumns($minNbColumns)
    {
        $this->minNbColumns = $minNbColumns;
        $this->maxNbColumns = max($this->maxNbColumns, $minNbColumns);
        return $this;
    }

Usage Example

Exemple #1
0
    public function testSetMinNbColumns()
    {
        $grid = new Grid(GridStyle::asciiBorder());
        $grid->setMinNbColumns(5);
        $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      | Dante Alighieri | 9971-5-0210-0 | A Tale of  |
|                 | Comedy      |                 |               | Two Cities |
+-----------------+-------------+-----------------+---------------+------------+
| Charles Dickens | 960-425-059 | The Lord of the | J. R. R.      | 80-902734- |
|                 | -0          | Rings           | Tolkien       | 1-6        |
+-----------------+-------------+-----------------+---------------+------------+
| And Then There  | Agatha      |                 |               |            |
| Were None       | Christie    |                 |               |            |
+-----------------+-------------+-----------------+---------------+------------+

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