| Conditions | 10 |
| Paths | 9 |
| Total Lines | 25 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 16 | function get_drupal_path() |
||
| 17 | { |
||
| 18 | if (!empty($_SERVER['SCRIPT_FILENAME'])) { |
||
| 19 | $drupal_path = dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])))); |
||
| 20 | if (!file_exists($drupal_path . '/includes/bootstrap.inc')) { |
||
| 21 | $drupal_path = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))); |
||
| 22 | $depth = 2; |
||
| 23 | do { |
||
| 24 | $drupal_path = dirname($drupal_path); |
||
| 25 | $depth++; |
||
| 26 | } while (!($bootstrap_file_found = file_exists($drupal_path . '/includes/bootstrap.inc')) && $depth < 10); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | if (!isset($bootstrap_file_found) || !$bootstrap_file_found) { |
||
| 31 | $drupal_path = '../../../../..'; |
||
| 32 | if (!file_exists($drupal_path . '/includes/bootstrap.inc')) { |
||
| 33 | $drupal_path = '../..'; |
||
| 34 | do { |
||
| 35 | $drupal_path .= '/..'; |
||
| 36 | $depth = substr_count($drupal_path, '..'); |
||
| 37 | } while (!($bootstrap_file_found = file_exists($drupal_path . '/includes/bootstrap.inc')) && $depth < 10); |
||
|
|
|||
| 38 | } |
||
| 39 | } |
||
| 40 | return $drupal_path; |
||
| 41 | } |
||
| 111 |