Conditions | 34 |
Paths | 1 |
Total Lines | 325 |
Code Lines | 212 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
116 | public static function parse_template_content(&$template) { |
||
117 | // balise banales avec contenu |
||
118 | // sans attributs |
||
119 | preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments(), function ($matches) use (&$template) { |
||
120 | $class = str_replace('-', '_', $matches[1]); |
||
121 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
122 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
123 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
124 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
125 | /** |
||
126 | * @var xphp_tag $tag |
||
127 | */ |
||
128 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
129 | $tag->value($matches[2]); |
||
130 | $template = str_replace($matches[0], $tag->render(), $template); |
||
131 | } |
||
132 | elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
133 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
134 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
135 | /** |
||
136 | * @var xphp_tag $tag |
||
137 | */ |
||
138 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
139 | $tag->value($matches[2]); |
||
140 | $template = str_replace($matches[0], $tag->render(), $template); |
||
141 | } |
||
142 | }, $template); |
||
143 | // sans attributs mais avec un espace |
||
144 | preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_not_arguments_and_spaces(), function ($matches) use (&$template) { |
||
145 | $class = str_replace('-', '_', $matches[1]); |
||
146 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
147 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
148 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
149 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
150 | /** |
||
151 | * @var xphp_tag $tag |
||
152 | */ |
||
153 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
154 | $tag->value($matches[2]); |
||
155 | $template = str_replace($matches[0], $tag->render(), $template); |
||
156 | } |
||
157 | elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
158 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
159 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
160 | /** |
||
161 | * @var xphp_tag $tag |
||
162 | */ |
||
163 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
164 | $tag->value($matches[2]); |
||
165 | $template = str_replace($matches[0], $tag->render(), $template); |
||
166 | } |
||
167 | }, $template); |
||
168 | // avec attributs |
||
169 | preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_with_content_and_arguments(), function ($matches) use (&$template) { |
||
170 | $class = str_replace('-', '_', $matches[1]); |
||
171 | |||
172 | $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
||
173 | $arguments_array = []; |
||
174 | preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
||
175 | $arguments_array[] = $matches[1]; |
||
176 | }, $arguments); |
||
177 | preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function ($matches) use (&$arguments_array) { |
||
178 | $arguments_array[] = $matches[1]; |
||
179 | }, $arguments); |
||
180 | foreach ($arguments_array as $id => $arg) { |
||
181 | $arg_local = explode('=', $arg); |
||
182 | $argument = $arg_local[0]; |
||
183 | $valeur = str_replace('\"', 'µ', $arg_local[1]); |
||
184 | $valeur = str_replace('"', '', $valeur); |
||
185 | $valeur = str_replace('µ', '"', $valeur); |
||
186 | |||
187 | $arguments_array[$argument] = $valeur; |
||
188 | unset($arguments_array[$id]); |
||
189 | } |
||
190 | $arguments_array['value'] = $matches[3]; |
||
191 | $arguments = $arguments_array; |
||
192 | |||
193 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
194 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
195 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
196 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
197 | /** |
||
198 | * @var xphp_tag $tag |
||
199 | */ |
||
200 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
201 | foreach ($arguments as $argument => $valeur) { |
||
202 | if ($argument === 'value') { |
||
203 | $tag->value($valeur); |
||
204 | } else { |
||
205 | $tag->attribute($argument, $valeur); |
||
206 | } |
||
207 | } |
||
208 | $template = str_replace($matches[0], $tag->render(), $template); |
||
209 | } |
||
210 | elseif (is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
211 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
212 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
213 | /** |
||
214 | * @var xphp_tag $tag |
||
215 | */ |
||
216 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
217 | foreach ($arguments as $argument => $valeur) { |
||
218 | if ($argument === 'value') { |
||
219 | $tag->value($valeur); |
||
220 | } else { |
||
221 | $tag->attribute($argument, $valeur); |
||
222 | } |
||
223 | } |
||
224 | $template = str_replace($matches[0], $tag->render(), $template); |
||
225 | } |
||
226 | }, $template); |
||
227 | |||
228 | // balises banales sans contenu |
||
229 | // sans attributs |
||
230 | preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments(), function ($matches) use (&$template) { |
||
231 | $class = str_replace('-', '_', $matches[1]); |
||
232 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
233 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
234 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
235 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
236 | /** |
||
237 | * @var xphp_tag $tag |
||
238 | */ |
||
239 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
240 | $template = str_replace($matches[0], $tag->render(), $template); |
||
241 | } |
||
242 | elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
243 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
244 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
245 | /** |
||
246 | * @var xphp_tag $tag |
||
247 | */ |
||
248 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
249 | $template = str_replace($matches[0], $tag->render(), $template); |
||
250 | } |
||
251 | }, $template); |
||
252 | // sans attributs mais avec un espace |
||
253 | preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_arguments_and_with_spaces(), function ($matches) use (&$template) { |
||
254 | $class = str_replace('-', '_', $matches[1]); |
||
255 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
256 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
257 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
258 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
259 | /** |
||
260 | * @var xphp_tag $tag |
||
261 | */ |
||
262 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
263 | $template = str_replace($matches[0], $tag->render(), $template); |
||
264 | } |
||
265 | elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
266 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
267 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
268 | /** |
||
269 | * @var xphp_tag $tag |
||
270 | */ |
||
271 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
272 | $template = str_replace($matches[0], $tag->render(), $template); |
||
273 | } |
||
274 | }, $template); |
||
275 | // avec attributs |
||
276 | preg_replace_callback(regexp::get_regexp_for_no_autoclosed_tags_without_content_and_with_arguments(), function ($matches) use (&$template) { |
||
277 | $class = str_replace('-', '_', $matches[1]); |
||
278 | $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
||
279 | $arguments_array = []; |
||
280 | preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
||
281 | $arguments_array[] = $matches[1]; |
||
282 | }, $arguments); |
||
283 | |||
284 | preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function ($matches) use (&$arguments_array) { |
||
285 | $arguments_array[] = $matches[1]; |
||
286 | }, $arguments); |
||
287 | |||
288 | foreach ($arguments_array as $id => $arg) { |
||
289 | $arg_local = explode('=', $arg); |
||
290 | $argument = $arg_local[0]; |
||
291 | $valeur = str_replace('\"', 'µ', $arg_local[1]); |
||
292 | $valeur = str_replace('"', '', $valeur); |
||
293 | $valeur = str_replace('µ', '"', $valeur); |
||
294 | |||
295 | $arguments_array[$argument] = $valeur; |
||
296 | unset($arguments_array[$id]); |
||
297 | } |
||
298 | |||
299 | $arguments = $arguments_array; |
||
300 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
301 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
302 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
303 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
304 | /** |
||
305 | * @var xphp_tag $tag |
||
306 | */ |
||
307 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
308 | foreach ($arguments as $argument => $valeur) { |
||
309 | if ($argument === 'value') { |
||
310 | $tag->value($valeur); |
||
311 | } else { |
||
312 | $tag->attribute($argument, $valeur); |
||
313 | } |
||
314 | } |
||
315 | $template = str_replace($matches[0], $tag->render(), $template); |
||
316 | } |
||
317 | elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
318 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
319 | $class_tag = "\\phoponent\\app\\component\\core\\class"; |
||
320 | /** |
||
321 | * @var xphp_tag $tag |
||
322 | */ |
||
323 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
324 | foreach ($arguments as $argument => $valeur) { |
||
325 | if ($argument === 'value') { |
||
326 | $tag->value($valeur); |
||
327 | } else { |
||
328 | $tag->attribute($argument, $valeur); |
||
329 | } |
||
330 | } |
||
331 | $template = str_replace($matches[0], $tag->render(), $template); |
||
332 | } |
||
333 | }, $template); |
||
334 | |||
335 | // balises autofermantes |
||
336 | // sans attributs |
||
337 | preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments(), function ($matches) use (&$template) { |
||
338 | $class = str_replace('-', '_', $matches[1]); |
||
339 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
340 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
341 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
342 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
343 | /** |
||
344 | * @var xphp_tag $tag |
||
345 | */ |
||
346 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
347 | $template = str_replace($matches[0], $tag->render(), $template); |
||
348 | } |
||
349 | elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
350 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
351 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
352 | /** |
||
353 | * @var xphp_tag $tag |
||
354 | */ |
||
355 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
356 | $template = str_replace($matches[0], $tag->render(), $template); |
||
357 | } |
||
358 | }, $template); |
||
359 | // sans attributs mais avec un espace |
||
360 | preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_without_arguments_and_spaces(), function ($matches) use (&$template) { |
||
361 | $class = str_replace('-', '_', $matches[1]); |
||
362 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
363 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
364 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
365 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
366 | /** |
||
367 | * @var xphp_tag $tag |
||
368 | */ |
||
369 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
370 | $template = str_replace($matches[0], $tag->render(), $template); |
||
371 | } |
||
372 | elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
373 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
374 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
375 | /** |
||
376 | * @var xphp_tag $tag |
||
377 | */ |
||
378 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
379 | $template = str_replace($matches[0], $tag->render(), $template); |
||
380 | } |
||
381 | }, $template); |
||
382 | // avec attributs |
||
383 | preg_replace_callback(regexp::get_regexp_for_autoclosed_tags_with_arguments(), function ($matches) use (&$template) { |
||
384 | $class = str_replace('-', '_', $matches[1]); |
||
385 | $arguments = str_replace(["\n", "\t"], '', $matches[2]); |
||
386 | $arguments_array = []; |
||
387 | preg_replace_callback(regexp::regexp_for_parse_attributs(), function ($matches) use (&$arguments_array) { |
||
388 | $arguments_array[] = $matches[1]; |
||
389 | }, $arguments); |
||
390 | |||
391 | preg_replace_callback(regexp::regexp_for_parse_attributs_with_only_integers(), function ($matches) use (&$arguments_array) { |
||
392 | $arguments_array[] = $matches[1]; |
||
393 | }, $arguments); |
||
394 | |||
395 | foreach ($arguments_array as $id => $arg) { |
||
396 | $arg_local = explode('=', $arg); |
||
397 | $argument = $arg_local[0]; |
||
398 | $valeur = str_replace('\"', 'µ', $arg_local[1]); |
||
399 | $valeur = str_replace('"', '', $valeur); |
||
400 | $valeur = str_replace('µ', '"', $valeur); |
||
401 | |||
402 | $arguments_array[$argument] = $valeur; |
||
403 | unset($arguments_array[$id]); |
||
404 | } |
||
405 | |||
406 | $arguments = $arguments_array; |
||
407 | if(is_file("phoponent/app/components/custom/{$class}/{$class}.php")) { |
||
408 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
409 | require_once "phoponent/app/components/custom/{$class}/{$class}.php"; |
||
410 | $class_tag = "\\phoponent\\app\\component\\custom\\$class"; |
||
411 | /** |
||
412 | * @var xphp_tag $tag |
||
413 | */ |
||
414 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
415 | foreach ($arguments as $argument => $valeur) { |
||
416 | if ($argument === 'value') { |
||
417 | $tag->value($valeur); |
||
418 | } else { |
||
419 | $tag->attribute($argument, $valeur); |
||
420 | } |
||
421 | } |
||
422 | $template = str_replace($matches[0], $tag->render(), $template); |
||
423 | } |
||
424 | elseif(is_file("phoponent/app/components/core/{$class}/{$class}.php")) { |
||
425 | require_once "phoponent/app/components/core/{$class}/{$class}.php"; |
||
426 | $class_tag = "\\phoponent\\app\\component\\core\\$class"; |
||
427 | /** |
||
428 | * @var xphp_tag $tag |
||
429 | */ |
||
430 | $tag = new $class_tag(self::get_models($class), self::get_views($class), self::get_services($class_tag), $template); |
||
431 | foreach ($arguments as $argument => $valeur) { |
||
432 | if ($argument === 'value') { |
||
433 | $tag->value($valeur); |
||
434 | } else { |
||
435 | $tag->attribute($argument, $valeur); |
||
436 | } |
||
437 | } |
||
438 | $template = str_replace($matches[0], $tag->render(), $template); |
||
439 | } |
||
440 | }, $template); |
||
441 | } |
||
442 | } |