solidBorder() public static method

A style that uses Unicode characters for drawing solid borders.
public static solidBorder ( ) : TableStyle
return TableStyle The style.
 public function handle(Args $args, IO $io, Command $command)
 {
     $tabular = Tabular::getInstance();
     $dom = new \DOMDocument('1.0');
     $dom->load($args->getArgument('xml'));
     $tableDom = $tabular->tabulate($dom, $args->getArgument('definition'));
     if ($args->getOption('debug')) {
         $io->writeLine($tableDom->saveXml());
     }
     $rows = $tableDom->toArray();
     $table = new Table(TableStyle::solidBorder());
     $table->setHeaderRow(array_keys(reset($rows) ?: array()));
     foreach ($rows as $row) {
         $table->addRow($row);
     }
     $table->render($io);
 }
Beispiel #2
0
    public function testRenderSolidBorder()
    {
        $table = new Table(TableStyle::solidBorder());
        $table->setHeaderRow(array('ISBN', 'Title', 'Author'));
        $table->addRows(array(array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie')));
        $table->render($this->io);
        $expected = <<<'EOF'
┌───────────────┬──────────────────────────┬──────────────────┐
│ ISBN          │ Title                    │ Author           │
├───────────────┼──────────────────────────┼──────────────────┤
│ 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());
    }