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 | * Tag noise |
||
38 | */ |
||
39 | protected $noise = ''; |
||
40 | |||
41 | /** |
||
42 | * The encoding class to... encode the tags |
||
43 | * |
||
44 | * @var mixed |
||
45 | */ |
||
46 | protected $encode = null; |
||
47 | |||
48 | /** |
||
49 | * Sets up the tag with a name. |
||
50 | * |
||
51 | * @param $name |
||
52 | */ |
||
53 | public function __construct($name) |
||
57 | |||
58 | /** |
||
59 | * Magic method to get any of the attributes. |
||
60 | * |
||
61 | * @param string $key |
||
62 | * @return mixed |
||
63 | */ |
||
64 | public function __get($key) |
||
68 | |||
69 | /** |
||
70 | * Magic method to set any attribute. |
||
71 | * |
||
72 | * @param string $key |
||
73 | * @param mixed $value |
||
74 | */ |
||
75 | public function __set($key, $value) |
||
79 | |||
80 | /** |
||
81 | * Returns the name of this tag. |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function name() |
||
89 | |||
90 | /** |
||
91 | * Sets the tag to be self closing. |
||
92 | * |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function selfClosing() |
||
101 | |||
102 | /** |
||
103 | * Checks if the tag is self closing. |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | public function isSelfClosing() |
||
111 | |||
112 | /** |
||
113 | * Sets the encoding type to be used. |
||
114 | * |
||
115 | * @param Encode $encode |
||
116 | */ |
||
117 | public function setEncoding(Encode $encode) |
||
121 | |||
122 | /** |
||
123 | * Sets the noise for this tag (if any) |
||
124 | * |
||
125 | * @param $noise |
||
126 | * @return $this |
||
127 | */ |
||
128 | public function noise($noise) |
||
134 | |||
135 | /** |
||
136 | * Set an attribute for this tag. |
||
137 | * |
||
138 | * @param string $key |
||
139 | * @param string|array $value |
||
140 | * @return $this |
||
141 | */ |
||
142 | public function setAttribute($key, $value) |
||
155 | |||
156 | /** |
||
157 | * Removes an attribute from this tag. |
||
158 | * |
||
159 | * @param $key |
||
160 | * @return void |
||
161 | */ |
||
162 | public function removeAttribute($key) |
||
167 | |||
168 | /** |
||
169 | * Removes all attributes on this tag. |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | public function removeAllAttributes() |
||
177 | |||
178 | /** |
||
179 | * Sets the attributes for this tag |
||
180 | * |
||
181 | * @param array $attr |
||
182 | * @return $this |
||
183 | */ |
||
184 | public function setAttributes(array $attr) |
||
192 | |||
193 | /** |
||
194 | * Returns all attributes of this tag. |
||
195 | * |
||
196 | * @return array |
||
197 | */ |
||
198 | public function getAttributes() |
||
207 | |||
208 | /** |
||
209 | * Returns an attribute by the key |
||
210 | * |
||
211 | * @param string $key |
||
212 | * @return mixed |
||
213 | */ |
||
214 | public function getAttribute($key) |
||
227 | |||
228 | /** |
||
229 | * Generates the opening tag for this object. |
||
230 | * |
||
231 | * @return string |
||
232 | */ |
||
233 | public function makeOpeningTag() |
||
256 | |||
257 | /** |
||
258 | * Generates the closing tag for this object. |
||
259 | * |
||
260 | * @return string |
||
261 | */ |
||
262 | public function makeClosingTag() |
||
270 | } |
||
271 |