Conditions | 10 |
Paths | 10 |
Total Lines | 35 |
Code Lines | 29 |
Lines | 0 |
Ratio | 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 | <? |
||
19 | private static function get_router_name() |
||
20 | { |
||
21 | if(Request::isAJAX()) |
||
22 | return 'AJAXRouter'; |
||
23 | if(URLDecode::getURI() == '/sitemap.xml') |
||
24 | return 'SitemapRouter'; |
||
25 | |||
26 | switch(URLDecode::getSite()) |
||
27 | { |
||
28 | case 'ajax' : |
||
29 | return 'AjaxRouter'; |
||
30 | break; |
||
31 | case 'blog' : |
||
32 | return 'BlogRouter'; |
||
33 | break; |
||
34 | case 'home' : |
||
35 | return 'HomeRouter'; |
||
36 | break; |
||
37 | case 'lifestream' : |
||
38 | return 'LifestreamRouter'; |
||
39 | break; |
||
40 | case 'portfolio' : |
||
41 | return 'PortfolioRouter'; |
||
42 | break; |
||
43 | case 'site' : |
||
44 | return 'SiteRouter'; |
||
45 | break; |
||
46 | case 'waterfalls' : |
||
47 | return 'WaterfallRouter'; |
||
48 | break; |
||
49 | } |
||
50 | |||
51 | Debugger::logMessage("The router for " . URLDecode::getSite() . " was not loaded."); |
||
52 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
||
53 | } |
||
54 | |||
148 |
Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.
As a precaution to avoid these problems better use the long opening tag
<?php
.