1 | <?php |
||
12 | class Tag |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * The name of the tag. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $name; |
||
21 | |||
22 | /** |
||
23 | * The attributes of the tag. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $attr = []; |
||
28 | |||
29 | /** |
||
30 | * Is this tag self closing. |
||
31 | * |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $selfClosing = false; |
||
35 | |||
36 | /** |
||
37 | * If self-closing, will this use a trailing slash. /> |
||
38 | * |
||
39 | * @var bool |
||
40 | */ |
||
41 | protected $trailingSlash = true; |
||
42 | |||
43 | /** |
||
44 | * Tag noise |
||
45 | */ |
||
46 | protected $noise = ''; |
||
47 | |||
48 | /** |
||
49 | * The encoding class to... encode the tags |
||
50 | * |
||
51 | * @var mixed |
||
52 | */ |
||
53 | protected $encode = null; |
||
54 | |||
55 | /** |
||
56 | * Sets up the tag with a name. |
||
57 | * |
||
58 | * @param $name |
||
59 | */ |
||
60 | public function __construct($name) |
||
64 | |||
65 | /** |
||
66 | * Magic method to get any of the attributes. |
||
67 | * |
||
68 | * @param string $key |
||
69 | * @return mixed |
||
70 | */ |
||
71 | public function __get($key) |
||
75 | |||
76 | /** |
||
77 | * Magic method to set any attribute. |
||
78 | * |
||
79 | * @param string $key |
||
80 | * @param mixed $value |
||
81 | */ |
||
82 | public function __set($key, $value) |
||
86 | |||
87 | /** |
||
88 | * Returns the name of this tag. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function name() |
||
96 | |||
97 | /** |
||
98 | * Sets the tag to be self closing. |
||
99 | * |
||
100 | * @return $this |
||
101 | */ |
||
102 | public function selfClosing() |
||
108 | |||
109 | |||
110 | /** |
||
111 | * Sets the tag to not use a trailing slash. |
||
112 | * |
||
113 | * @return $this |
||
114 | */ |
||
115 | public function noTrailingSlash() |
||
121 | |||
122 | /** |
||
123 | * Checks if the tag is self closing. |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | public function isSelfClosing() |
||
131 | |||
132 | /** |
||
133 | * Sets the encoding type to be used. |
||
134 | * |
||
135 | * @param Encode $encode |
||
136 | */ |
||
137 | public function setEncoding(Encode $encode) |
||
141 | |||
142 | /** |
||
143 | * Sets the noise for this tag (if any) |
||
144 | * |
||
145 | * @param $noise |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function noise($noise) |
||
154 | |||
155 | /** |
||
156 | * Set an attribute for this tag. |
||
157 | * |
||
158 | * @param string $key |
||
159 | * @param string|array $value |
||
160 | * @return $this |
||
161 | */ |
||
162 | public function setAttribute($key, $value) |
||
175 | |||
176 | /** |
||
177 | * Removes an attribute from this tag. |
||
178 | * |
||
179 | * @param $key |
||
180 | * @return void |
||
181 | */ |
||
182 | public function removeAttribute($key) |
||
187 | |||
188 | /** |
||
189 | * Removes all attributes on this tag. |
||
190 | * |
||
191 | * @return void |
||
192 | */ |
||
193 | public function removeAllAttributes() |
||
197 | |||
198 | /** |
||
199 | * Sets the attributes for this tag |
||
200 | * |
||
201 | * @param array $attr |
||
202 | * @return $this |
||
203 | */ |
||
204 | public function setAttributes(array $attr) |
||
212 | |||
213 | /** |
||
214 | * Returns all attributes of this tag. |
||
215 | * |
||
216 | * @return array |
||
217 | */ |
||
218 | public function getAttributes() |
||
227 | |||
228 | /** |
||
229 | * Returns an attribute by the key |
||
230 | * |
||
231 | * @param string $key |
||
232 | * @return mixed |
||
233 | */ |
||
234 | public function getAttribute($key) |
||
247 | |||
248 | /** |
||
249 | * Generates the opening tag for this object. |
||
250 | * |
||
251 | * @return string |
||
252 | */ |
||
253 | public function makeOpeningTag() |
||
276 | |||
277 | /** |
||
278 | * Generates the closing tag for this object. |
||
279 | * |
||
280 | * @return string |
||
281 | */ |
||
282 | public function makeClosingTag() |
||
290 | } |
||
291 |