Conditions | 10 |
Paths | 132 |
Total Lines | 42 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 110 |
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 |
||
64 | function display() { |
||
65 | if(is_admin($GLOBALS['current_user'])) { |
||
66 | $json = getJSONobj(); |
||
67 | require_once('include/QuickSearchDefaults.php'); |
||
68 | $qsd = QuickSearchDefaults::getQuickSearchDefaults(); |
||
69 | $sqs_objects = array('EditView_reports_to_name' => $qsd->getQSUser()); |
||
70 | $sqs_objects['EditView_reports_to_name']['populate_list'] = array('reports_to_name', 'reports_to_id'); |
||
71 | $quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '; enableQS();</script>'; |
||
72 | |||
73 | $this->ss->assign('REPORTS_TO_JS', $quicksearch_js); |
||
74 | $this->ss->assign('EDIT_REPORTS_TO', true); |
||
75 | } |
||
76 | |||
77 | |||
78 | //retrieve employee bean if it is not already in focus |
||
79 | if(empty($this->bean->id) && !empty($_REQUEST['record'])){ |
||
80 | $this->bean->retrieve($_REQUEST['record']); |
||
81 | } |
||
82 | //populate values for non admin users |
||
83 | if(!empty($this->bean->id)) { |
||
84 | global $app_list_strings; |
||
85 | if( !empty($this->bean->status) ) { |
||
86 | $this->ss->assign('STATUS_READONLY',$app_list_strings['user_status_dom'][$this->bean->status]); } |
||
87 | if( !empty($this->bean->employee_status) ) { |
||
88 | $this->ss->assign('EMPLOYEE_STATUS_READONLY', $app_list_strings['employee_status_dom'][$this->bean->employee_status]); |
||
89 | } |
||
90 | if( !empty($this->bean->reports_to_id) ) { |
||
91 | $reportsToUser = get_assigned_user_name($this->bean->reports_to_id); |
||
92 | $reportsToUserField = "<input type='text' name='reports_to_name' id='reports_to_name' value='{$reportsToUser}' disabled>\n"; |
||
93 | $reportsToUserField .= "<input type='hidden' name='reports_to_id' id='reports_to_id' value='{$this->bean->reports_to_id}'>"; |
||
94 | $this->ss->assign('REPORTS_TO_READONLY', $reportsToUserField); |
||
95 | } |
||
96 | if( !empty($this->bean->title) ) { |
||
97 | $this->ss->assign('TITLE_READONLY', $this->bean->title); |
||
98 | } |
||
99 | if( !empty($this->bean->department) ) { |
||
100 | $this->ss->assign('DEPT_READONLY', $this->bean->department); |
||
101 | } |
||
102 | } |
||
103 | |||
104 | parent::display(); |
||
105 | } |
||
106 | } |
||
108 |