Conditions | 9 |
Paths | 28 |
Total Lines | 97 |
Code Lines | 75 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 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 |
||
49 | function load_autoload($name){ |
||
50 | static $classes = null; |
||
51 | if(is_null($classes)) $classes = array( |
||
52 | 'DokuHTTPClient' => DOKU_INC.'inc/HTTPClient.php', |
||
53 | 'HTTPClient' => DOKU_INC.'inc/HTTPClient.php', |
||
54 | 'JSON' => DOKU_INC.'inc/JSON.php', |
||
55 | 'Diff' => DOKU_INC.'inc/DifferenceEngine.php', |
||
56 | 'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', |
||
57 | 'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php', |
||
58 | 'cache' => DOKU_INC.'inc/cache.php', |
||
59 | 'cache_parser' => DOKU_INC.'inc/cache.php', |
||
60 | 'cache_instructions' => DOKU_INC.'inc/cache.php', |
||
61 | 'cache_renderer' => DOKU_INC.'inc/cache.php', |
||
62 | 'Doku_Event' => DOKU_INC.'inc/events.php', |
||
63 | 'Doku_Event_Handler' => DOKU_INC.'inc/events.php', |
||
64 | 'EmailAddressValidator' => DOKU_INC.'inc/EmailAddressValidator.php', |
||
65 | 'Input' => DOKU_INC.'inc/Input.class.php', |
||
66 | 'JpegMeta' => DOKU_INC.'inc/JpegMeta.php', |
||
67 | 'SimplePie' => DOKU_INC.'inc/SimplePie.php', |
||
68 | 'FeedParser' => DOKU_INC.'inc/FeedParser.php', |
||
69 | 'IXR_Server' => DOKU_INC.'inc/IXR_Library.php', |
||
70 | 'IXR_Client' => DOKU_INC.'inc/IXR_Library.php', |
||
71 | 'IXR_IntrospectionServer' => DOKU_INC.'inc/IXR_Library.php', |
||
72 | 'Doku_Plugin_Controller'=> DOKU_INC.'inc/plugincontroller.class.php', |
||
73 | 'Tar' => DOKU_INC.'inc/Tar.class.php', |
||
74 | 'ZipLib' => DOKU_INC.'inc/ZipLib.class.php', |
||
75 | 'DokuWikiFeedCreator' => DOKU_INC.'inc/feedcreator.class.php', |
||
76 | 'Doku_Parser_Mode' => DOKU_INC.'inc/parser/parser.php', |
||
77 | 'Doku_Parser_Mode_Plugin' => DOKU_INC.'inc/parser/parser.php', |
||
78 | 'SafeFN' => DOKU_INC.'inc/SafeFN.class.php', |
||
79 | 'Sitemapper' => DOKU_INC.'inc/Sitemapper.php', |
||
80 | 'PassHash' => DOKU_INC.'inc/PassHash.class.php', |
||
81 | 'Mailer' => DOKU_INC.'inc/Mailer.class.php', |
||
82 | 'RemoteAPI' => DOKU_INC.'inc/remote.php', |
||
83 | 'RemoteAPICore' => DOKU_INC.'inc/RemoteAPICore.php', |
||
84 | 'Subscription' => DOKU_INC.'inc/subscription.php', |
||
85 | 'Crypt_Base' => DOKU_INC.'inc/phpseclib/Crypt_Base.php', |
||
86 | 'Crypt_Rijndael' => DOKU_INC.'inc/phpseclib/Crypt_Rijndael.php', |
||
87 | 'Crypt_AES' => DOKU_INC.'inc/phpseclib/Crypt_AES.php', |
||
88 | 'Crypt_Hash' => DOKU_INC.'inc/phpseclib/Crypt_Hash.php', |
||
89 | 'lessc' => DOKU_INC.'inc/lessc.inc.php', |
||
90 | |||
91 | 'DokuWiki_Action_Plugin' => DOKU_PLUGIN.'action.php', |
||
92 | 'DokuWiki_Admin_Plugin' => DOKU_PLUGIN.'admin.php', |
||
93 | 'DokuWiki_Syntax_Plugin' => DOKU_PLUGIN.'syntax.php', |
||
94 | 'DokuWiki_Remote_Plugin' => DOKU_PLUGIN.'remote.php', |
||
95 | 'DokuWiki_Auth_Plugin' => DOKU_PLUGIN.'auth.php', |
||
96 | |||
97 | 'Doku_Renderer' => DOKU_INC.'inc/parser/renderer.php', |
||
98 | 'Doku_Renderer_xhtml' => DOKU_INC.'inc/parser/xhtml.php', |
||
99 | 'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php', |
||
100 | 'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php', |
||
101 | 'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php', |
||
102 | |||
103 | 'DokuCLI' => DOKU_INC.'inc/cli.php', |
||
104 | 'DokuCLI_Options' => DOKU_INC.'inc/cli.php', |
||
105 | 'DokuCLI_Colors' => DOKU_INC.'inc/cli.php', |
||
106 | |||
107 | ); |
||
108 | |||
109 | if(isset($classes[$name])){ |
||
110 | require ($classes[$name]); |
||
111 | return true; |
||
112 | } |
||
113 | |||
114 | // namespace to directory conversion |
||
115 | $name = str_replace('\\', '/', $name); |
||
116 | |||
117 | // plugin namespace |
||
118 | if(substr($name, 0, 16) == 'dokuwiki/plugin/') { |
||
119 | $name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace |
||
120 | $file = DOKU_PLUGIN . substr($name, 16) . '.php'; |
||
121 | if(file_exists($file)) { |
||
122 | require $file; |
||
123 | return true; |
||
124 | } |
||
125 | } |
||
126 | |||
127 | // our own namespace |
||
128 | if(substr($name, 0, 9) == 'dokuwiki/') { |
||
129 | require substr($name, 9) . '.php'; |
||
130 | return true; |
||
131 | } |
||
132 | |||
133 | // Plugin loading |
||
134 | if(preg_match('/^(auth|helper|syntax|action|admin|renderer|remote)_plugin_('.DOKU_PLUGIN_NAME_REGEX.')(?:_([^_]+))?$/', |
||
135 | $name, $m)) { |
||
136 | // try to load the wanted plugin file |
||
137 | $c = ((count($m) === 4) ? "/{$m[3]}" : ''); |
||
138 | $plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php"; |
||
139 | if(file_exists($plg)){ |
||
140 | require $plg; |
||
141 | } |
||
142 | return true; |
||
143 | } |
||
144 | return false; |
||
145 | } |
||
146 | |||
147 |