| Conditions | 20 | 
| Paths | 208 | 
| Total Lines | 131 | 
| Code Lines | 73 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 0 | 
| CRAP Score | 420 | 
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:
Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.
There are several approaches to avoid long parameter lists:
| 1 | <?php  | 
            ||
| 271 | 	function processListNavigation( $xtpl, $html_varName, $current_offset, $display_audit_link = false , $next_offset = null, $previous_offset = null, $row_count = null, $sugarbean = NULL, $subpanel_def = NULL, $col_count = 20){ | 
            ||
| 272 | global $export_module, $sugar_config, $current_user;  | 
            ||
| 273 | //intialize audit_link  | 
            ||
| 274 | $audit_link = '';  | 
            ||
| 275 | |||
| 276 | $row_count = $this->getListViewRowCount();  | 
            ||
| 277 | |||
| 278 | if($display_audit_link && (!isset($sugar_config['disc_client']) || $sugar_config['disc_client'] == false))  | 
            ||
| 279 |         { | 
            ||
| 280 | //Audit link  | 
            ||
| 281 | $popup_request_data = array(  | 
            ||
| 282 | 'call_back_function' => 'set_return',  | 
            ||
| 283 | 'form_name' => 'EditView',  | 
            ||
| 284 | 'field_to_name_array' => array(),  | 
            ||
| 285 | );  | 
            ||
| 286 | $json = getJSONobj();  | 
            ||
| 287 | $encoded_popup_request_data = $json->encode($popup_request_data);  | 
            ||
| 288 | $audit_link = "<a href='javascript:void(0)' onclick='open_popup(\"Audit\", \"600\", \"400\", \"&record=".$_REQUEST['record']."&module_name=".$_REQUEST['module']."\", true, false, $encoded_popup_request_data);'>".$this->local_app_strings['LNK_VIEW_CHANGE_LOG']."</a>";  | 
            ||
| 289 | }  | 
            ||
| 290 | |||
| 291 | $html_text = "";  | 
            ||
| 292 | $pre_html_text = "";  | 
            ||
| 293 | $pre_html_text .= "<tr class='pagination'>\n";  | 
            ||
| 294 | $pre_html_text .= "<td COLSPAN=\"20\">\n";  | 
            ||
| 295 | $pre_html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td style=\"text-align: left\" > ".$audit_link."</td>\n";  | 
            ||
| 296 | |||
| 297 | |||
| 298 | |||
| 299 |         if ($this->return_to_list_only == true) { | 
            ||
| 300 | if($current_offset != 0 && $this->isRequestFromListView($html_varName))  | 
            ||
| 301 | 	        { | 
            ||
| 302 | 	    		if($current_offset < 0){ | 
            ||
| 303 | $current_offset = 1;  | 
            ||
| 304 | }  | 
            ||
| 305 | 	    		else if($current_offset > $row_count){ | 
            ||
| 306 | $current_offset = $row_count;  | 
            ||
| 307 | }  | 
            ||
| 308 | |||
| 309 | $this->set_base_URL($html_varName);  | 
            ||
| 310 | $list_URL = $this->base_URL.'&action=index&module='.$_REQUEST['module'];  | 
            ||
| 311 | $current_page = floor($current_offset / $this->records_per_page) * $this->records_per_page;  | 
            ||
| 312 | |||
| 313 | $list_URL .= '&'.$this->getSessionVariableName($html_varName,"offset").'='.$current_page;  | 
            ||
| 314 | //$list_link = "<a href=\"$list_URL\" >".$this->local_app_strings['LNK_LIST_RETURN']." </a>";  | 
            ||
| 315 | 				$list_link = "<button type='button' class='button' title='{$GLOBALS['app_strings']['LNK_LIST_RETURN']}' onClick='location.href=\"$list_URL\";'>".$this->local_app_strings['LNK_LIST_RETURN']."</button>"; | 
            ||
| 316 | |||
| 317 | $html_text .= "<td nowrap align='right' scope='row'>".$list_link;  | 
            ||
| 318 | |||
| 319 | 				if ($row_count != 0) { | 
            ||
| 320 | $resume_URL = $this->base_URL.$current_offset."&InDetailNav=1";  | 
            ||
| 321 | //$resume_link = "<a href=\"$resume_URL\" >".$this->local_app_strings['LNK_RESUME']." </a>";  | 
            ||
| 322 | $resume_link = "<button type='button' class='button' title='$this->local_app_strings['LNK_RESUME']' onClick='location.href=\"$resume_URL\";'>".$this->local_app_strings['LNK_RESUME']."</button>";  | 
            ||
| 323 | |||
| 324 | $html_text .= "  ".$resume_link;  | 
            ||
| 325 | }  | 
            ||
| 326 | $html_text .= "</td>";  | 
            ||
| 327 | }  | 
            ||
| 328 | }  | 
            ||
| 329 | 		else { | 
            ||
| 330 | if($current_offset != 0 && $this->isRequestFromListView($html_varName))  | 
            ||
| 331 | 	        { | 
            ||
| 332 | 	    		if($current_offset < 0){ | 
            ||
| 333 | $current_offset = 1;  | 
            ||
| 334 | }  | 
            ||
| 335 | 	    		else if($current_offset > $row_count){ | 
            ||
| 336 | $current_offset = $row_count;  | 
            ||
| 337 | }  | 
            ||
| 338 | |||
| 339 | $next_offset = $current_offset + 1;  | 
            ||
| 340 | $previous_offset = $current_offset - 1;  | 
            ||
| 341 | |||
| 342 | $this->set_base_URL($html_varName);  | 
            ||
| 343 | |||
| 344 | $start_URL = $this->base_URL."1"."&InDetailNav=1";  | 
            ||
| 345 | $current_URL = $this->base_URL.$current_offset."&InDetailNav=1";  | 
            ||
| 346 | $previous_URL = $this->base_URL.$previous_offset."&InDetailNav=1";  | 
            ||
| 347 | $next_URL = $this->base_URL.$next_offset."&InDetailNav=1";  | 
            ||
| 348 | $end_URL = $this->base_URL.$row_count."&InDetailNav=1";  | 
            ||
| 349 | |||
| 350 | $current_page = floor($current_offset / $this->records_per_page) * $this->records_per_page;  | 
            ||
| 351 | |||
| 352 | 	    		if(1 == $current_offset){ | 
            ||
| 353 | 	    			//$start_link = SugarThemeRegistry::current()->getImage("start_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])." ".$this->local_app_strings['LNK_LIST_START']; | 
            ||
| 354 | 	   				//$previous_link = SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])." ".$this->local_app_strings['LNK_LIST_PREVIOUS'].""; | 
            ||
| 355 | 					$start_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>"; | 
            ||
| 356 | 					$previous_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; | 
            ||
| 357 | |||
| 358 | 	   			}else{ | 
            ||
| 359 | 	   				//$start_link = "<a href=\"$start_URL\">".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</a> <a href=\"$start_URL\">".$this->local_app_strings['LNK_LIST_START']."</a>"; | 
            ||
| 360 | 					$start_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\";'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>"; | 
            ||
| 361 | |||
| 362 | 	   				if(0 != $current_offset){ | 
            ||
| 363 | 		   				//$previous_link = "<a href=\"$previous_URL\">".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</a> <a href=\"$previous_URL\" >".$this->local_app_strings['LNK_LIST_PREVIOUS']."</a>"; | 
            ||
| 364 | 						$previous_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\";'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; | 
            ||
| 365 | }  | 
            ||
| 366 | 	    			else { | 
            ||
| 367 | 	    				//$previous_link = SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])." ".$this->local_app_strings['LNK_LIST_PREVIOUS']; | 
            ||
| 368 | 						$previous_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>"; | 
            ||
| 369 | |||
| 370 | }  | 
            ||
| 371 | }  | 
            ||
| 372 | |||
| 373 | |||
| 374 | 	    		if($row_count <= $current_offset){ | 
            ||
| 375 | 	    			//$end_link = $this->local_app_strings['LNK_LIST_END']." ".SugarThemeRegistry::current()->getImage("end_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END']); | 
            ||
| 376 | 	    			//$next_link = $this->local_app_strings['LNK_LIST_NEXT']." ".SugarThemeRegistry::current()->getImage("next_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT']); | 
            ||
| 377 | 					$end_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>"; | 
            ||
| 378 | 					$next_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>"; | 
            ||
| 379 | }  | 
            ||
| 380 | 	    		else{ | 
            ||
| 381 | 	    			//$end_link = "<a href=\"$end_URL\">".$this->local_app_strings['LNK_LIST_END']."</a> <a href=\"$end_URL\">".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</a>"; | 
            ||
| 382 | 	    			//$next_link = "<a href=\"$next_URL\">".$this->local_app_strings['LNK_LIST_NEXT']."</a> <a href=\"$next_URL\">".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",,null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</a>"; | 
            ||
| 383 | 					$end_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\";'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>"; | 
            ||
| 384 | 					$next_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\";'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>"; | 
            ||
| 385 | |||
| 386 | }  | 
            ||
| 387 | |||
| 388 | 	    		$html_text .= "<td nowrap align='right' >".$start_link."  ".$previous_link."  (".$current_offset." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")  ".$next_link."  ".$end_link."</td>"; | 
            ||
| 389 | |||
| 390 | }  | 
            ||
| 391 | }  | 
            ||
| 392 | $post_html_text = "</tr></table>\n";  | 
            ||
| 393 | $post_html_text .= "</td>\n";  | 
            ||
| 394 | $post_html_text .= "</tr>\n";  | 
            ||
| 395 | $showVCRControl = true;  | 
            ||
| 396 | 		if(isset($sugar_config['disable_vcr'])) { | 
            ||
| 397 | $showVCRControl = !$sugar_config['disable_vcr'];  | 
            ||
| 398 | }  | 
            ||
| 399 | if ( $showVCRControl && $html_text != "" )  | 
            ||
| 400 | 		    $xtpl->assign("PAGINATION",$pre_html_text.$html_text.$post_html_text); | 
            ||
| 401 | }  | 
            ||
| 402 | |||
| 485 | 
On one hand,
evalmight be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM,evalprevents some optimization that they perform.