3 namespace Caxy\HtmlDiff\Table;
8 class TableRow extends AbstractTableElement
18 protected $cells = array();
23 public function getTable()
29 * @param Table|null $table
33 public function setTable(Table $table = null)
35 $this->table = $table;
37 if ($table && !in_array($this, $table->getRows())) {
38 $table->addRow($this);
47 public function getCells()
53 * @param TableCell $cell
57 public function addCell(TableCell $cell)
59 $this->cells[] = $cell;
61 if (!$cell->getRow()) {
69 * @param TableCell $cell
71 public function removeCell(TableCell $cell)
73 $key = array_search($cell, $this->cells, true);
76 unset($this->cells[$key]);
77 if ($cell->getRow()) {
86 * @return TableCell|null
88 public function getCell($index)
90 return isset($this->cells[$index]) ? $this->cells[$index] : null;
94 * @param TableCell[] $cells
95 * @param null|int $position
97 public function insertCells($cells, $position = null)
99 if ($position === null) {
100 $this->cells = array_merge($this->cells, $cells);
102 array_splice($this->cells, $position, 0, $cells);