Completed
Push — master ( b569b1...d88325 )
by Jean-Christophe
03:46
created

HtmlTable::getBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Ajax\semantic\html\collections;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\content\table\HtmlTableContent;
7
8
class HtmlTable extends HtmlSemDoubleElement {
9
	private $_colCount;
10
	public function __construct($identifier, $rowCount, $colCount) {
11
		parent::__construct($identifier, "table", "ui table");
12
		$this->content=array();
13
		$this->setRowCount($rowCount, $colCount);
14
	}
15
16
	/**
17
	 * @param string $key
18
	 * @return HtmlTableContent
19
	 */
20
	private function getPart($key){
21
		if(\array_key_exists($key, $this->content)===false){
22
			$this->content[$key]=new HtmlTableContent("",$key);
23
			if($key!=="tbody"){
24
				$this->content[$key]->setRowCount(1, $this->_colCount);
25
			}
26
		}
27
		return $this->content[$key];
28
	}
29
30
	public function getBody(){
31
		return $this->getPart("tbody");
32
	}
33
34
	public function getHeader(){
35
		return $this->getPart("thead");
36
	}
37
38
	public function getFooter(){
39
		return $this->getPart("tfoot");
40
	}
41
42
	public function hasPart($key){
43
		return \array_key_exists($key, $this->content)===true;
44
	}
45
46
	public function setRowCount($rowCount, $colCount) {
47
		$this->_colCount=$colCount;
48
		return $this->getBody()->setRowCount($rowCount,$colCount);
49
	}
50
51
	/**
52
	 * Returns the cell (HtmlTD) at position $row,$col
53
	 * @param int $row
54
	 * @param int $col
55
	 * @return \Ajax\semantic\html\content\HtmlTD
56
	 */
57
	public function getCell($row,$col){
58
		return $this->getBody()->getCell($row,$col);
59
	}
60
61
	public function setValues($values=array()){
62
		$this->getBody()->setValues($values);
63
	}
64
}