1 | <?php |
||
5 | class DiffListItem |
||
6 | { |
||
7 | protected $attributes = array(); |
||
8 | |||
9 | protected $text; |
||
10 | |||
11 | protected $startTag; |
||
12 | |||
13 | protected $endTag; |
||
14 | |||
15 | public function __construct($text, $attributes = array(), $startTag, $endTag) |
||
|
|||
16 | { |
||
17 | $this->text = $text; |
||
18 | $this->attributes = $attributes; |
||
19 | $this->startTag = $startTag; |
||
20 | $this->endTag = $endTag; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @return array |
||
25 | */ |
||
26 | public function getAttributes() |
||
30 | |||
31 | /** |
||
32 | * @param array $attributes |
||
33 | * |
||
34 | * @return DiffListItem |
||
35 | */ |
||
36 | public function setAttributes($attributes) |
||
42 | |||
43 | /** |
||
44 | * @return mixed |
||
45 | */ |
||
46 | public function getText() |
||
47 | { |
||
48 | return $this->text; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param mixed $text |
||
53 | * |
||
54 | * @return DiffListItem |
||
55 | */ |
||
56 | public function setText($text) |
||
62 | |||
63 | /** |
||
64 | * @return mixed |
||
65 | */ |
||
66 | public function getStartTag() |
||
70 | |||
71 | public function getStartTagWithDiffClass($class = 'normal') |
||
72 | { |
||
73 | return str_replace('>', ' class="'.$class.'">', $this->startTag); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param mixed $startTag |
||
78 | * |
||
79 | * @return DiffListItem |
||
80 | */ |
||
81 | public function setStartTag($startTag) |
||
87 | |||
88 | /** |
||
89 | * @return mixed |
||
90 | */ |
||
91 | public function getEndTag() |
||
92 | { |
||
93 | return $this->endTag; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @param mixed $endTag |
||
98 | * |
||
99 | * @return DiffListItem |
||
100 | */ |
||
101 | public function setEndTag($endTag) |
||
107 | |||
108 | public function getHtml($class = 'normal', $wrapTag = null) |
||
109 | { |
||
110 | $startWrap = $wrapTag ? sprintf('<%s>', $wrapTag) : ''; |
||
111 | $endWrap = $wrapTag ? sprintf('</%s>', $wrapTag) : ''; |
||
112 | |||
113 | return sprintf('%s%s%s%s%s', $this->getStartTagWithDiffClass($class), $startWrap, $this->getInnerHtml(), $endWrap, $this->endTag); |
||
114 | } |
||
115 | |||
116 | public function getInnerHtml() |
||
117 | { |
||
118 | return implode('', $this->text); |
||
119 | } |
||
120 | |||
121 | public function __toString() |
||
125 | } |
||
126 |
If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway: