Conditions | 27 |
Paths | 42 |
Total Lines | 126 |
Code Lines | 57 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
177 | function getFilesChanged($from, $to) |
||
178 | { |
||
179 | global $settings; |
||
180 | |||
181 | $output = shell_exec('git diff --name-only --pretty=oneline --full-index ' . $from . '..' . $to . ' | sort | uniq'); |
||
182 | if (empty($output)) |
||
183 | { |
||
184 | echo "The git command failed to return any results\n"; |
||
185 | //die; |
||
186 | } |
||
187 | |||
188 | $dirs = array( |
||
189 | str_replace(BOARDDIR . '/', '', SOURCEDIR . '/database/') => 'database', |
||
190 | str_replace(BOARDDIR . '/', '', SUBSDIR . '/') => 'subs', |
||
191 | str_replace(BOARDDIR . '/', '', CONTROLLERDIR . '/') => 'controllers', |
||
192 | str_replace(BOARDDIR . '/', '', SOURCEDIR . '/') => 'sources', |
||
193 | str_replace(BOARDDIR . '/', '', ADMINDIR . '/') => 'admin', |
||
194 | str_replace(BOARDDIR . '/', '', ADMINDIR . '/') => 'admin', |
||
195 | str_replace(BOARDDIR . '/', '', $settings['theme_dir'] . '/') => 'default', |
||
196 | ); |
||
197 | |||
198 | $files = array_filter(explode("\n", $output)); |
||
199 | $list = array(); |
||
200 | foreach ($files as $file) |
||
201 | { |
||
202 | if ($file[0] === '.') |
||
203 | { |
||
204 | continue; |
||
205 | } |
||
206 | |||
207 | if (strpos($file, 'install') !== false) |
||
208 | { |
||
209 | continue; |
||
210 | } |
||
211 | |||
212 | if (strpos($file, 'release_tools') !== false) |
||
213 | { |
||
214 | continue; |
||
215 | } |
||
216 | |||
217 | if (strpos($file, '/ext') !== false) |
||
218 | { |
||
219 | continue; |
||
220 | } |
||
221 | |||
222 | if (strpos($file, 'tests') !== false) |
||
223 | { |
||
224 | continue; |
||
225 | } |
||
226 | |||
227 | if (strpos($file, 'fonts') !== false) |
||
228 | { |
||
229 | continue; |
||
230 | } |
||
231 | |||
232 | if (strpos($file, '/scripts') !== false) |
||
233 | { |
||
234 | continue; |
||
235 | } |
||
236 | |||
237 | if (strpos($file, 'docs/') !== false) |
||
238 | { |
||
239 | continue; |
||
240 | } |
||
241 | |||
242 | if (strpos($file, '/images') !== false) |
||
243 | { |
||
244 | continue; |
||
245 | } |
||
246 | |||
247 | if (strpos($file, '/css') !== false) |
||
248 | { |
||
249 | continue; |
||
250 | } |
||
251 | |||
252 | if (strpos($file, '/languages') !== false) |
||
253 | { |
||
254 | continue; |
||
255 | } |
||
256 | |||
257 | if (strpos($file, 'packages') !== false) |
||
258 | { |
||
259 | continue; |
||
260 | } |
||
261 | |||
262 | if (strpos($file, '.txt') !== false || strpos($file, '.json') !== false) |
||
263 | { |
||
264 | continue; |
||
265 | } |
||
266 | |||
267 | if ($file === 'index.php') |
||
268 | { |
||
269 | continue; |
||
270 | } |
||
271 | |||
272 | if ($file === 'ssi_examples.php') |
||
273 | { |
||
274 | continue; |
||
275 | } |
||
276 | |||
277 | if ($file === 'ssi_examples.shtml') |
||
278 | { |
||
279 | continue; |
||
280 | } |
||
281 | |||
282 | if ($file === 'elkServiceWorker.min.js') |
||
283 | { |
||
284 | continue; |
||
285 | } |
||
286 | |||
287 | if ($file === 'SSI.php') |
||
288 | { |
||
289 | $list[] = 'sourcesSSI.php'; |
||
290 | continue; |
||
291 | } |
||
292 | |||
293 | if ($file === 'subscriptions.php' || $file === 'bootstrap.php' || $file === 'email_imap_cron.php' || $file === 'emailpost.php' || $file === 'emailtopic.php') |
||
294 | { |
||
295 | $list[] = 'sources' . $file; |
||
296 | continue; |
||
297 | } |
||
298 | |||
299 | $list[] = strtr($file, $dirs); |
||
300 | } |
||
301 | |||
302 | return $list; |
||
303 | } |
||
304 |