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

HtmlTD   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 51
Duplicated Lines 31.37 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 9
c 3
b 0
f 0
lcom 1
cbo 2
dl 16
loc 51
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setContainer() 0 5 1
A setValue() 0 4 1
A setRowspan() 8 8 2
A mergeRow() 0 3 1
A mergeCol() 0 3 1
A setColspan() 8 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}