| Conditions | 16 |
| Paths | 194 |
| Total Lines | 74 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 168.873 |
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 |
||
| 82 | 5 | static function menu($module, $offset, $isAuditEnabled, $saveAndContinue = false ){ |
|
| 83 | 5 | $html_text = ""; |
|
| 84 | 5 | if ($offset < 0) |
|
| 85 | { |
||
| 86 | $offset = 0; |
||
| 87 | } |
||
| 88 | |||
| 89 | //this check if require in cases when you visit the edit view before visiting that modules list view. |
||
| 90 | //you can do this easily either from home, activities or sitemap. |
||
| 91 | 5 | $stored_vcr_query = SugarVCR::retrieve($module); |
|
| 92 | |||
| 93 | // bug 15893 - only show VCR if called as an element in a set of records |
||
| 94 | 5 | if (!empty($_REQUEST['record']) and !empty($stored_vcr_query) and isset($_REQUEST['offset']) and (empty($_REQUEST['isDuplicate']) or $_REQUEST['isDuplicate'] == 'false')) |
|
| 95 | { |
||
| 96 | //syncing with display offset; |
||
| 97 | $offset ++; |
||
| 98 | $action = (!empty($_REQUEST['action']) ? $_REQUEST['action'] : 'EditView'); |
||
| 99 | |||
| 100 | $menu = SugarVCR::play($module, $offset); |
||
| 101 | |||
| 102 | $list_link = ''; |
||
| 103 | if ($saveAndContinue && !empty($menu['NEXT'])) |
||
| 104 | { |
||
| 105 | $list_link = ajaxLink('index.php?action=' . $action . '&module=' . $module . '&record=' . $menu['NEXT'] . '&offset=' . ($offset + 1)); |
||
| 106 | } |
||
| 107 | |||
| 108 | $previous_link = ""; |
||
| 109 | if (!empty($menu['PREV'])) |
||
| 110 | { |
||
| 111 | $previous_link = ajaxLink('index.php?module=' . $module . '&action=' . $action . '&offset=' . ($offset - 1) . '&record=' . $menu['PREV']); |
||
| 112 | } |
||
| 113 | |||
| 114 | $next_link = ""; |
||
| 115 | if (!empty($menu['NEXT'])) |
||
| 116 | { |
||
| 117 | $next_link = ajaxLink('index.php?module=' . $module . '&action=' . $action . '&offset=' . ($offset + 1) . '&record=' . $menu['NEXT']); |
||
| 118 | } |
||
| 119 | |||
| 120 | $ss = new Sugar_Smarty(); |
||
| 121 | $ss->assign('app_strings', $GLOBALS['app_strings']); |
||
| 122 | $ss->assign('module', $module); |
||
| 123 | $ss->assign('action', $action); |
||
| 124 | $ss->assign('menu', $menu); |
||
| 125 | $ss->assign('list_link', $list_link); |
||
| 126 | $ss->assign('previous_link', $previous_link); |
||
| 127 | $ss->assign('next_link', $next_link); |
||
| 128 | |||
| 129 | $ss->assign('offset', $offset); |
||
| 130 | $ss->assign('total', ''); |
||
| 131 | $ss->assign('plus', ''); |
||
| 132 | |||
| 133 | if (!empty($_SESSION[$module . 'total'])) |
||
| 134 | { |
||
| 135 | $ss->assign('total', $_SESSION[$module . 'total']); |
||
| 136 | if ( |
||
| 137 | !empty($GLOBALS['sugar_config']['disable_count_query']) |
||
| 138 | && (($_SESSION[$module. 'total']-1) % $GLOBALS['sugar_config']['list_max_entries_per_page'] == 0) |
||
| 139 | ) |
||
| 140 | { |
||
| 141 | $ss->assign('plus', '+'); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | |||
| 145 | if (is_file('custom/include/EditView/SugarVCR.tpl')) |
||
| 146 | { |
||
| 147 | $html_text .= $ss->fetch('custom/include/EditView/SugarVCR.tpl'); |
||
| 148 | } |
||
| 149 | else |
||
| 150 | { |
||
| 151 | $html_text .= $ss->fetch('include/EditView/SugarVCR.tpl'); |
||
| 152 | } |
||
| 153 | } |
||
| 154 | 5 | return $html_text; |
|
| 155 | } |
||
| 156 | |||
| 195 |