1 | <?php |
||
10 | class Html { |
||
11 | |||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $tag = ''; |
||
16 | |||
17 | /** |
||
18 | * @var null|string |
||
19 | */ |
||
20 | protected $content = null; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $attributes = []; |
||
26 | |||
27 | |||
28 | /** |
||
29 | * @return string |
||
30 | */ |
||
31 | 2 | public function __toString() { |
|
34 | |||
35 | |||
36 | /** |
||
37 | * @deprecated |
||
38 | * @param $name |
||
39 | * @param $arguments |
||
40 | * @return $this|null |
||
41 | * @throws \Exception |
||
42 | */ |
||
43 | public function __call($name, $arguments) { |
||
44 | trigger_error('Deprecated', E_USER_DEPRECATED); |
||
45 | if (strpos($name, 'set') === 0 and isset($arguments[0])) { |
||
46 | $name = strtolower(substr($name, 3)); |
||
47 | $this->setAttribute($name, $arguments[0]); |
||
48 | return $this; |
||
49 | } elseif (strpos($name, 'get') === 0 and !isset($arguments[0])) { |
||
50 | return $this->getAttribute(strtolower(substr($name, 3))); |
||
51 | } else { |
||
52 | throw new \Exception('Invalid method: ' . $name); |
||
53 | } |
||
54 | } |
||
55 | |||
56 | |||
57 | /** |
||
58 | * @param string $className |
||
59 | * @return $this |
||
60 | */ |
||
61 | 2 | public function addClass($className) { |
|
72 | |||
73 | |||
74 | /** |
||
75 | * @param array $attributes |
||
76 | * @return string |
||
77 | */ |
||
78 | 9 | public static function renderAttributes(array $attributes = []) { |
|
85 | |||
86 | |||
87 | /** |
||
88 | * |
||
89 | * @param string $tag |
||
90 | * @param array $attributes |
||
91 | * @param bool $content |
||
92 | * @return string |
||
93 | */ |
||
94 | 7 | public static function tag($tag, array $attributes, $content = null) { |
|
105 | |||
106 | |||
107 | /** |
||
108 | * @return array |
||
109 | */ |
||
110 | 5 | public function getAttributes() { |
|
113 | |||
114 | |||
115 | /** |
||
116 | * @param array $attributes |
||
117 | * @return $this |
||
118 | */ |
||
119 | 5 | public function setAttributes(array $attributes) { |
|
125 | |||
126 | |||
127 | /** |
||
128 | * Add multiple attributes |
||
129 | * |
||
130 | * @param array $attributes |
||
131 | * @return $this |
||
132 | */ |
||
133 | 3 | public function addAttributes(array $attributes) { |
|
137 | |||
138 | |||
139 | /** |
||
140 | * @param string $name |
||
141 | * @param string $value |
||
142 | * @return $this |
||
143 | */ |
||
144 | 27 | public function setAttribute($name, $value) { |
|
148 | |||
149 | |||
150 | /** |
||
151 | * @param string $name |
||
152 | * @return $this |
||
153 | */ |
||
154 | 3 | public function removeAttribute($name) { |
|
158 | |||
159 | |||
160 | /** |
||
161 | * @param string $name Attribute name |
||
162 | * @return string|null |
||
163 | */ |
||
164 | 23 | public function getAttribute($name) { |
|
167 | |||
168 | |||
169 | /** |
||
170 | * @return string |
||
171 | */ |
||
172 | public function getAttributesAsString() { |
||
176 | |||
177 | |||
178 | /** |
||
179 | * @return string |
||
180 | */ |
||
181 | 6 | public function render() { |
|
184 | |||
185 | |||
186 | /** |
||
187 | * @return null|string |
||
188 | */ |
||
189 | 6 | public function getContent() { |
|
192 | |||
193 | |||
194 | /** |
||
195 | * @return string |
||
196 | */ |
||
197 | public function getTag() { |
||
200 | |||
201 | |||
202 | /** |
||
203 | * @param string $tag |
||
204 | * @return $this |
||
205 | */ |
||
206 | 1 | public function setTag($tag) { |
|
213 | |||
214 | } |
This check looks at variables that 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.