示例#1
0
 /**
  * @param array $rows
  *
  * @return array
  */
 private function calculateColumnWidths(array $rows)
 {
     $widths = [];
     foreach ($rows as $row) {
         if ($row['type'] !== '@row') {
             continue;
         }
         foreach ($row['cols'] as $colIndex => $col) {
             $currentWidth = array_get($widths, $colIndex, 0);
             $col = $this->output->format($col, OutputFormat::PLAIN);
             $width = strlen($col);
             if ($width > $currentWidth) {
                 $widths[$colIndex] = $width;
             }
         }
     }
     return $widths;
 }