See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
1 <?php 2 3 namespace Box\Spout\Common\Entity; 4 5 use Box\Spout\Common\Entity\Style\Style; 6 7 class Row 8 { 9 /** 10 * The cells in this row 11 * @var Cell[] 12 */ 13 protected $cells = []; 14 15 /** 16 * The row style 17 * @var Style 18 */ 19 protected $style; 20 21 /** 22 * Row constructor. 23 * @param Cell[] $cells 24 * @param Style|null $style 25 */ 26 public function __construct(array $cells, $style) 27 { 28 $this 29 ->setCells($cells) 30 ->setStyle($style); 31 } 32 33 /** 34 * @return Cell[] $cells 35 */ 36 public function getCells() 37 { 38 return $this->cells; 39 } 40 41 /** 42 * @param Cell[] $cells 43 * @return Row 44 */ 45 public function setCells(array $cells) 46 { 47 $this->cells = []; 48 foreach ($cells as $cell) { 49 $this->addCell($cell); 50 } 51 52 return $this; 53 } 54 55 /** 56 * @param Cell $cell 57 * @param int $cellIndex 58 * @return Row 59 */ 60 public function setCellAtIndex(Cell $cell, $cellIndex) 61 { 62 $this->cells[$cellIndex] = $cell; 63 64 return $this; 65 } 66 67 /** 68 * @param int $cellIndex 69 * @return Cell|null 70 */ 71 public function getCellAtIndex($cellIndex) 72 { 73 return $this->cells[$cellIndex] ?? null; 74 } 75 76 /** 77 * @param Cell $cell 78 * @return Row 79 */ 80 public function addCell(Cell $cell) 81 { 82 $this->cells[] = $cell; 83 84 return $this; 85 } 86 87 /** 88 * @return int 89 */ 90 public function getNumCells() 91 { 92 // When using "setCellAtIndex", it's possible to 93 // have "$this->cells" contain holes. 94 if (empty($this->cells)) { 95 return 0; 96 } 97 98 return \max(\array_keys($this->cells)) + 1; 99 } 100 101 /** 102 * @return Style 103 */ 104 public function getStyle() 105 { 106 return $this->style; 107 } 108 109 /** 110 * @param Style|null $style 111 * @return Row 112 */ 113 public function setStyle($style) 114 { 115 $this->style = $style ?: new Style(); 116 117 return $this; 118 } 119 120 /** 121 * @return array The row values, as array 122 */ 123 public function toArray() 124 { 125 return \array_map(function (Cell $cell) { 126 return $cell->getValue(); 127 }, $this->cells); 128 } 129 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body