fill = new Fill(); // Cells for ($inc = 0; $inc < $columns; ++$inc) { $this->cells[] = new Cell(); } } /** * Get cell. * * @param int $cell Cell number * * @throws OutOfBoundsException */ public function getCell(int $cell = 0): Cell { if (!isset($this->cells[$cell])) { throw new OutOfBoundsException( 0, (\count($this->cells) - 1) < 0 ? \count($this->cells) - 1 : 0, $cell ); } return $this->cells[$cell]; } /** * Get cell. * * @param int $cell Cell number * * @return bool */ public function hasCell(int $cell): bool { return isset($this->cells[$cell]); } /** * Get cells. * * @return array */ public function getCells(): array { return $this->cells; } /** * Next cell (moves one cell to the right). * * @return Cell * * @throws OutOfBoundsException */ public function nextCell(): Cell { ++$this->activeCellIndex; if (isset($this->cells[$this->activeCellIndex])) { $this->cells[$this->activeCellIndex]->setFill(clone $this->getFill()); return $this->cells[$this->activeCellIndex]; } throw new OutOfBoundsException( 0, (\count($this->cells) - 1) < 0 ? \count($this->cells) - 1 : 0, $this->activeCellIndex ); } /** * Get fill. * * @return Fill */ public function getFill(): Fill { return $this->fill; } /** * Set fill. * * @return self */ public function setFill(Fill $fill): self { $this->fill = $fill; return $this; } /** * Get height. * * @return int */ public function getHeight(): int { return $this->height; } /** * Set height. * * @param int $value * * @return self */ public function setHeight(int $value = 0): self { $this->height = $value; return $this; } /** * Get hash code. * * @return string Hash code */ public function getHashCode(): string { $hashElements = ''; foreach ($this->cells as $cell) { $hashElements .= $cell->getHashCode(); } return \md5($hashElements . $this->fill->getHashCode() . $this->height . __CLASS__); } /** * Get hash index. * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @return int|null Hash index */ public function getHashIndex(): ?int { return $this->hashIndex; } /** * Set hash index. * * Note that this index may vary during script execution! Only reliable moment is * while doing a write of a workbook and when changes are not allowed. * * @param int $value Hash index * * @return $this */ public function setHashIndex(int $value) { $this->hashIndex = $value; return $this; } }