setCells($cells) ->setStyle($style); } /** * @return Cell[] $cells */ public function getCells() { return $this->cells; } /** * @param Cell[] $cells * @return Row */ public function setCells(array $cells) { $this->cells = []; foreach ($cells as $cell) { $this->addCell($cell); } return $this; } /** * @param Cell $cell * @param mixed $cellIndex * @parma int $cellIndex * @return Row */ public function setCellAtIndex(Cell $cell, $cellIndex) { $this->cells[$cellIndex] = $cell; return $this; } /** * @param Cell $cell * @return Row */ public function addCell(Cell $cell) { $this->cells[] = $cell; return $this; } /** * @return int */ public function getNumCells() { return count($this->cells); } /** * @return Style */ public function getStyle() { return $this->style; } /** * @param Style|null $style * @return Row */ public function setStyle($style) { $this->style = $style ?: new Style(); return $this; } /** * @return array The row values, as array */ public function toArray() { return array_map(function (Cell $cell) { return !$cell->isError() ? $cell->getValue() : null; }, $this->cells); } }