Completed
Push — master ( 66af5c...1d23a1 )
by Jean-Christophe
03:38
created

HtmlTD::colMerge()   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\content\table;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\base\traits\TextAlignmentTrait;
7
8
class HtmlTD extends HtmlSemDoubleElement {
9
	use TextAlignmentTrait;
10
	private $_container;
11
	private $_row;
12
	private $_col;
13
	/**
14
	 * @param string $identifier
15
	 * @param mixed $content
16
	 * @param string $tagName
17
	 */
18
	public function __construct($identifier,$content=NULL,$tagName="td") {
19
		parent::__construct($identifier, $tagName, "", $content);
20
	}
21
22
	public function setContainer($container,$row,$col){
23
		$this->_container=$container;
24
		$this->_row=$row;
25
		$this->_col=$col;
26
	}
27
28
	public function setValue($value){
29
		$this->content=$value;
30
		return $this;
31
	}
32
33 View Code Duplication
	public function setRowspan($rowspan){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
		$to=min($this->_container->count(),$this->_row+$rowspan-1);
35
		for($i=$to;$i>$this->_row;$i--){
36
			$this->_container->delete($this->_row+1,$this->_col);
37
		}
38
		$this->setProperty("rowspan", $rowspan);
39
		return $this->_container;
40
	}
41
42
	public function mergeRow(){
43
		return $this->setRowspan($this->_container->count());
44
	}
45
46
	public function mergeCol(){
47
		return $this->setColspan($this->_container->getRow($this->_row)->count());
48
	}
49
50 View Code Duplication
	public function setColspan($colspan){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
		$to=min($this->_container->getRow($this->_row)->count(),$this->_col+$colspan-1);
52
		for($i=$to;$i>$this->_col;$i--){
53
			$this->_container->delete($this->_row,$this->_col+1);
54
		}
55
		$this->setProperty("colspan", $colspan);
56
		return $this->_container;
57
	}
58
}