1 | <?php |
||
24 | abstract class HeadAbstract extends Singleton implements HeadInterface |
||
25 | { |
||
26 | /** |
||
27 | * collection namespace |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | |||
32 | protected static $_namespace = 'Redaxscript\Head'; |
||
33 | |||
34 | /** |
||
35 | * collection of the head |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | |||
40 | protected static $_collectionArray = []; |
||
41 | |||
42 | /** |
||
43 | * stringify the collection |
||
44 | * |
||
45 | * @since 3.0.0 |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | 25 | ||
50 | public function __toString() : string |
||
59 | |||
60 | /** |
||
61 | * init the class |
||
62 | * |
||
63 | * @param string $namespace collection sub namespace |
||
64 | * |
||
65 | * @since 3.0.0 |
||
66 | * |
||
67 | * @return self |
||
68 | */ |
||
69 | 26 | ||
70 | public function init(string $namespace = null) : self |
||
79 | |||
80 | /** |
||
81 | * append to the collection |
||
82 | * |
||
83 | * @since 3.0.0 |
||
84 | * |
||
85 | * @param string|array $attribute key or array of attributes |
||
86 | * @param string $value value of the attribute |
||
87 | * |
||
88 | * @return self |
||
89 | */ |
||
90 | 8 | ||
91 | public function append($attribute = null, string $value = null) : self |
||
108 | |||
109 | /** |
||
110 | * prepend to the collection |
||
111 | * |
||
112 | * @since 3.0.0 |
||
113 | * |
||
114 | * @param string|array $attribute key or array of attributes |
||
115 | * @param string $value value of the attribute |
||
116 | * |
||
117 | * @return self |
||
118 | */ |
||
119 | 4 | ||
120 | public function prepend($attribute = null, string $value = null) : self |
||
137 | |||
138 | /** |
||
139 | * remove from to the collection |
||
140 | * |
||
141 | * @since 3.0.0 |
||
142 | * |
||
143 | * @param string $attribute name of attribute |
||
144 | * @param string $value value of the attribute |
||
145 | * |
||
146 | * @return self |
||
147 | */ |
||
148 | 2 | ||
149 | public function remove(string $attribute = null, string $value = null) : self |
||
165 | |||
166 | /** |
||
167 | * clear the collection |
||
168 | * |
||
169 | * @since 3.0.0 |
||
170 | * |
||
171 | * @return self |
||
172 | */ |
||
173 | 25 | ||
174 | public function clear() : self |
||
179 | |||
180 | /** |
||
181 | * get the collection array |
||
182 | * |
||
183 | * @since 3.0.0 |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | 25 | ||
188 | protected function _getCollectionArray() : array |
||
192 | |||
193 | /** |
||
194 | * set the collection array |
||
195 | * |
||
196 | * @since 3.0.0 |
||
197 | * |
||
198 | * @param array $collectionArray |
||
199 | */ |
||
200 | 25 | ||
201 | protected function _setCollectionArray(array $collectionArray = []) : void |
||
205 | } |
||
206 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: