Total Complexity | 14 |
Total Lines | 95 |
Duplicated Lines | 0 % |
Coverage | 55.56% |
Changes | 0 |
1 | <?php |
||
8 | class TableRow extends AbstractTableElement |
||
9 | { |
||
10 | /** |
||
11 | * @var Table |
||
12 | */ |
||
13 | protected $table; |
||
14 | |||
15 | /** |
||
16 | * @var TableCell[] |
||
17 | */ |
||
18 | protected $cells = array(); |
||
19 | |||
20 | /** |
||
21 | * @return Table |
||
22 | */ |
||
23 | 1 | public function getTable() |
|
24 | { |
||
25 | 1 | return $this->table; |
|
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param Table|null $table |
||
30 | * |
||
31 | * @return $this |
||
32 | */ |
||
33 | 1 | public function setTable(Table $table = null) |
|
34 | { |
||
35 | 1 | $this->table = $table; |
|
36 | |||
37 | 1 | if ($table && !in_array($this, $table->getRows())) { |
|
38 | $table->addRow($this); |
||
39 | } |
||
40 | |||
41 | 1 | return $this; |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return TableCell[] |
||
46 | */ |
||
47 | 1 | public function getCells() |
|
48 | { |
||
49 | 1 | return $this->cells; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param TableCell $cell |
||
54 | * |
||
55 | * @return $this |
||
56 | */ |
||
57 | 1 | public function addCell(TableCell $cell) |
|
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param TableCell $cell |
||
70 | */ |
||
71 | public function removeCell(TableCell $cell) |
||
72 | { |
||
73 | $key = array_search($cell, $this->cells, true); |
||
74 | |||
75 | if ($key !== false) { |
||
76 | unset($this->cells[$key]); |
||
77 | if ($cell->getRow()) { |
||
78 | $cell->setRow(null); |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @param int $index |
||
85 | * |
||
86 | * @return TableCell|null |
||
87 | */ |
||
88 | 1 | public function getCell($index) |
|
89 | { |
||
90 | 1 | return isset($this->cells[$index]) ? $this->cells[$index] : null; |
|
91 | } |
||
92 | |||
93 | /** |
||
94 | * @param TableCell[] $cells |
||
95 | * @param null|int $position |
||
96 | */ |
||
97 | public function insertCells($cells, $position = null) |
||
103 | } |
||
104 | } |
||
105 | } |
||
106 |