1 <?php 2 3 declare(strict_types=1); 4 5 namespace OpenSpout\Writer\Common; 6 7 use OpenSpout\Common\Entity\Style\Style; 8 use OpenSpout\Common\TempFolderOptionTrait; 9 10 abstract class AbstractOptions 11 { 12 use TempFolderOptionTrait; 13 14 public Style $DEFAULT_ROW_STYLE; 15 public bool $SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY = true; 16 public ?float $DEFAULT_COLUMN_WIDTH = null; 17 public ?float $DEFAULT_ROW_HEIGHT = null; 18 19 /** @var ColumnWidth[] Array of min-max-width arrays */ 20 private array $COLUMN_WIDTHS = []; 21 22 public function __construct() 23 { 24 $this->DEFAULT_ROW_STYLE = new Style(); 25 } 26 27 /** 28 * @param positive-int ...$columns One or more columns with this width 29 */ 30 final public function setColumnWidth(float $width, int ...$columns): void 31 { 32 // Gather sequences 33 $sequence = []; 34 foreach ($columns as $column) { 35 $sequenceLength = \count($sequence); 36 if ($sequenceLength > 0) { 37 $previousValue = $sequence[$sequenceLength - 1]; 38 if ($column !== $previousValue + 1) { 39 $this->setColumnWidthForRange($width, $sequence[0], $previousValue); 40 $sequence = []; 41 } 42 } 43 $sequence[] = $column; 44 } 45 $this->setColumnWidthForRange($width, $sequence[0], $sequence[\count($sequence) - 1]); 46 } 47 48 /** 49 * @param float $width The width to set 50 * @param positive-int $start First column index of the range 51 * @param positive-int $end Last column index of the range 52 */ 53 final public function setColumnWidthForRange(float $width, int $start, int $end): void 54 { 55 $this->COLUMN_WIDTHS[] = new ColumnWidth($start, $end, $width); 56 } 57 58 /** 59 * @internal 60 * 61 * @return ColumnWidth[] 62 */ 63 final public function getColumnWidths(): array 64 { 65 return $this->COLUMN_WIDTHS; 66 } 67 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body