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

HtmlTR::createItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\content\table;
4
5
use Ajax\semantic\html\base\HtmlSemCollection;
6
7
class HtmlTR extends HtmlSemCollection{
8
9
	private $_tdTagName;
10
	private $_container;
11
	private $_row;
12
13
	public function __construct( $identifier, $colCount){
14
		parent::__construct( $identifier, "tr", "");
15
	}
16
17
	public function setColCount($colCount){
18
		$count=$this->count();
19
		for($i=$count;$i<$colCount;$i++){
20
			$item=$this->addItem(NULL);
21
			$item->setTagName($this->_tdTagName);
22
		}
23
		return $this;
24
	}
25
26
27
	protected function createItem($value){
28
		$count=$this->count();
29
		$td=new HtmlTD("",$this->_container,$value,$this->_tdTagName);
0 ignored issues
show
Bug introduced by
It seems like $value defined by parameter $value on line 27 can also be of type object<Ajax\common\html\HtmlDoubleElement>; however, Ajax\semantic\html\conte...e\HtmlTD::__construct() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Unused Code introduced by
The call to HtmlTD::__construct() has too many arguments starting with $this->_tdTagName.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
30
		$td->setContainer($this->_container, $this->_row, $count);
31
		return $td;
32
	}
33
34
	public function setTdTagName($tagName="td"){
35
		$this->_tdTagName=$tagName;
36
	}
37
38
	public function setContainer($container,$row){
39
		$this->_container=$container;
40
		$this->_row=$row;
41
	}
42
43 View Code Duplication
	public function setValues($values=array()){
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...
44
		$count=$this->count();
45
		if(\is_array($values)===false){
46
			$values=\array_fill(0, $count, $values);
47
		}
48
		$count=\min(\sizeof($values),$count);
49
50
		for ($i=0;$i<$count;$i++){
51
			$cell=$this->content[$i];
52
			$cell->setValue($values[$i]);
53
		}
54
	}
55
56
	public function delete($index){
57
		$this->removeItem($index);
58
		return $this;
59
	}
60
}