Completed
Push — master ( 686575...778966 )
by Jean-Christophe
03:10
created

HtmlInput   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 36
Duplicated Lines 19.44 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 7
loc 36
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A setValue() 0 5 2
A setInputType() 0 3 1
A setPlaceholder() 0 5 2
A compile() 0 9 3

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\html5;
4
5
use Ajax\common\html\HtmlSingleElement;
6
use Ajax\service\JString;
7
use Ajax\JsUtils;
8
9
class HtmlInput extends HtmlSingleElement {
10
	protected $_placeholder;
11 View Code Duplication
	public function __construct($identifier,$type="text",$value=NULL,$placeholder=NULL) {
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...
12
		parent::__construct($identifier, "input");
13
		$this->setProperty("name", $identifier);
14
		$this->setValue($value);
15
		$this->setPlaceholder($placeholder);
16
		$this->setProperty("type", $type);
17
	}
18
19
	public function setValue($value) {
20
		if(isset($value))
21
		$this->setProperty("value", $value);
22
		return $this;
23
	}
24
25
	public function setInputType($value) {
26
		return $this->setProperty("type", $value);
27
	}
28
29
	public function setPlaceholder($value){
30
		if(JString::isNotNull($value))
31
			$this->_placeholder=$value;
32
		return $this;
33
	}
34
35
	public function compile(JsUtils $js=NULL,&$view=NULL){
36
		$value=$this->_placeholder;
37
		if(JString::isNull($value)){
38
			if(JString::isNotNull($this->getProperty("name")))
39
				$value=\ucfirst($this->getProperty("name"));
40
		}
41
		$this->setProperty("placeholder", $value);
42
		return parent::compile($js,$view);
43
	}
44
}