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) { |
|
|
|
|
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) { |
|
|
|
|
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
|
|
|
} |
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.