| 
<?php
 /*
 * Copyright 2008 Sam Barnett-Cormack
 *
 * This file is part of PHPTables.
 *
 * PHPTables is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Foobar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 class Row implements IteratorAggregate {
 
 private $cells = array();
 public $style_class = NULL;
 
 public function getIterator() {
 return new ArrayIterator($this->cells);
 }
 
 function get_width() {
 $count = 0;
 foreach ($this->cells as $cell) {
 $count += $cell->span;
 }
 return $count;
 }
 
 function empty_row() {
 $this->cells = array();
 }
 
 function add_cell(Cell $cell) {
 $this->cells[] = $cell;
 }
 
 function get_cell_at_column($index) {
 $count = 0;
 foreach ($this->cells as $cell) {
 $count += $cell->span;
 if ($count > $index) {
 return $cell;
 }
 }
 throw new InvalidArgumentException("Column index out of bounds");
 }
 
 function get_cells_as_array() {
 $returnarray = array();
 foreach ($this->cells as $cell) {
 $returnarray[] = $cell;
 }
 return $returnarray;
 }
 
 
 }
 
 ?>
 
 |