| Conditions | 13 |
| Paths | 144 |
| Total Lines | 65 |
| Code Lines | 40 |
| 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 |
||
| 86 | |||
| 87 | if ($where == 'before') |
||
| 88 | $offset--; |
||
| 89 | |||
| 90 | $haystack = array_slice($haystack, 0, $offset, true) + $needle + array_slice($haystack, $offset, null, true); |
||
| 91 | } |
||
| 92 | else |
||
| 93 | foreach ($haystack as $stack) |
||
| 94 | if (array_key_exists($insertion_point, $haystack[$stack])) |
||
| 95 | { |
||
| 96 | $offset = 0; |
||
| 97 | |||
| 98 | foreach ($haystack[$stack] as $area => $dummy) |
||
| 99 | if (++$offset && $area == $insertion_point) |
||
| 100 | break; |
||
| 101 | |||
| 102 | if ($where == 'before') |
||
| 103 | $offset--; |
||
| 104 | |||
| 105 | $haystack[$stack] = array_slice($haystack[$stack], 0, $offset, true) + $needle + array_slice($haystack[$stack], $offset, null, true); |
||
| 106 | break; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | function um_admin_areas(&$admin_areas) |
||
| 111 | { |
||
| 112 | global $txt; |
||
| 113 | |||
| 114 | loadLanguage('ManageUltimateMenu'); |
||
| 115 | $admin_areas['config']['areas']['umen'] = array( |
||
| 116 | 'label' => $txt['um_admin_menu'], |
||
| 117 | 'file' => 'ManageUltimateMenu.php', |
||
| 118 | 'function' => function () { |
||
| 119 | new ManageUltimateMenu; |
||
| 120 | }, |
||
| 121 | 'icon' => 'umen.png', |
||
| 122 | 'subsections' => array( |
||
| 123 | 'manmenu' => array($txt['um_admin_manage_menu'], ''), |
||
| 124 | 'addbutton' => array($txt['um_admin_add_button'], ''), |
||
| 125 | ), |
||
| 126 | ); |
||
| 127 | } |
||
| 128 | |||
| 129 | ?> |
||
| 130 |