Completed
Push — master ( 0b3773...ca057c )
by Jean-Christophe
03:07
created

HtmlSingleElement   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 57
Duplicated Lines 24.56 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 1
dl 14
loc 57
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setClass() 7 7 2
A addClass() 7 7 2
A setRole() 0 4 1
A setTitle() 0 4 1
A run() 0 3 1
A fromArray() 0 7 2
A setSize() 0 2 1

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\common\html;
4
5
use Ajax\JsUtils;
6
7
class HtmlSingleElement extends BaseHtml {
8
9
	public function __construct($identifier, $tagName="br") {
10
		parent::__construct($identifier);
11
		$this->tagName=$tagName;
12
		$this->_template="<%tagName% id='%identifier%' %properties%/>";
13
	}
14
15 View Code Duplication
	public function setClass($classNames) {
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...
16
		if(\is_array($classNames)){
17
			$classNames=implode(" ", $classNames);
18
		}
19
		$this->setProperty("class", $classNames);
20
		return $this;
21
	}
22
23 View Code Duplication
	public function addClass($classNames) {
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...
24
		if(\is_array($classNames)){
25
			$classNames=implode(" ", $classNames);
26
		}
27
		$this->addToProperty("class", $classNames);
28
		return $this;
29
	}
30
31
	public function setRole($value) {
32
		$this->setProperty("role", $value);
33
		return $this;
34
	}
35
36
	public function setTitle($value) {
37
		$this->setProperty("title", $value);
38
		return $this;
39
	}
40
41
	/*
42
	 * (non-PHPdoc)
43
	 * @see \Ajax\bootstrap\html\base\HtmlSingleElement::run()
44
	 */
45
	public function run(JsUtils $js) {
46
47
	}
48
49
	/*
50
	 * (non-PHPdoc)
51
	 * @see \Ajax\bootstrap\html\BaseHtml::fromArray()
52
	 */
53
	public function fromArray($array) {
54
		$array=parent::fromArray($array);
55
		foreach ( $array as $key => $value ) {
56
			$this->setProperty($key, $value);
57
		}
58
		return $array;
59
	}
60
61
	public function setSize($size) {
62
	}
63
}