Conditions | 29 |
Paths | 5760 |
Total Lines | 108 |
Code Lines | 77 |
Lines | 12 |
Ratio | 11.11 % |
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 |
||
41 | function getMemberList() |
||
42 | { |
||
43 | // Search option |
||
44 | $args = new stdClass(); |
||
45 | $args->is_admin = Context::get('is_admin')=='Y'?'Y':''; |
||
46 | $args->is_denied = Context::get('is_denied')=='Y'?'Y':''; |
||
47 | $args->selected_group_srl = Context::get('selected_group_srl'); |
||
48 | |||
49 | $filter = Context::get('filter_type'); |
||
50 | switch($filter) |
||
51 | { |
||
52 | case 'super_admin' : $args->is_admin = 'Y';break; |
||
53 | case 'site_admin' : $args->member_srls = $this->getSiteAdminMemberSrls();break; |
||
54 | case 'enable' : $args->is_denied = 'N';break; |
||
55 | case 'disable' : $args->is_denied = 'Y';break; |
||
56 | } |
||
57 | |||
58 | $search_target = trim(Context::get('search_target')); |
||
59 | $search_keyword = trim(Context::get('search_keyword')); |
||
60 | |||
61 | if($search_target && $search_keyword) |
||
62 | { |
||
63 | switch($search_target) |
||
64 | { |
||
65 | View Code Duplication | case 'user_id' : |
|
66 | if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
||
67 | $args->s_user_id = $search_keyword; |
||
68 | break; |
||
69 | View Code Duplication | case 'user_name' : |
|
70 | if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
||
71 | $args->s_user_name = $search_keyword; |
||
72 | break; |
||
73 | case 'nick_name' : |
||
74 | if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
||
75 | $args->s_nick_name = $search_keyword; |
||
76 | $args->html_nick_name = htmlspecialchars($search_keyword, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
||
77 | break; |
||
78 | View Code Duplication | case 'email_address' : |
|
79 | if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); |
||
80 | $args->s_email_address = $search_keyword; |
||
81 | break; |
||
82 | case 'regdate' : |
||
83 | $args->s_regdate = preg_replace("/[^0-9]/","",$search_keyword); |
||
84 | break; |
||
85 | case 'regdate_more' : |
||
86 | $args->s_regdate_more = substr(preg_replace("/[^0-9]/","",$search_keyword) . '00000000000000',0,14); |
||
87 | break; |
||
88 | case 'regdate_less' : |
||
89 | $args->s_regdate_less = substr(preg_replace("/[^0-9]/","",$search_keyword) . '00000000000000',0,14); |
||
90 | break; |
||
91 | case 'last_login' : |
||
92 | $args->s_last_login = preg_replace("/[^0-9]/","",$search_keyword); |
||
93 | //$args->s_last_login = $search_keyword; |
||
94 | break; |
||
95 | case 'last_login_more' : |
||
96 | $args->s_last_login_more = substr(preg_replace("/[^0-9]/","",$search_keyword) . '00000000000000',0,14); |
||
97 | break; |
||
98 | case 'last_login_less' : |
||
99 | $args->s_last_login_less = substr(preg_replace("/[^0-9]/","",$search_keyword) . '00000000000000',0,14); |
||
100 | break; |
||
101 | case 'birthday' : |
||
102 | $args->s_birthday = preg_replace("/[^0-9]/","",$search_keyword); |
||
103 | break; |
||
104 | case 'extra_vars' : |
||
105 | $args->s_extra_vars = $search_keyword; |
||
106 | break; |
||
107 | } |
||
108 | } |
||
109 | |||
110 | // Change the query id if selected_group_srl exists (for table join) |
||
111 | $sort_order = Context::get('sort_order'); |
||
112 | $sort_index = Context::get('sort_index'); |
||
113 | if(!$sort_index) |
||
114 | { |
||
115 | $sort_index = "list_order"; |
||
116 | } |
||
117 | |||
118 | if(!$sort_order) |
||
119 | { |
||
120 | $sort_order = 'asc'; |
||
121 | } |
||
122 | |||
123 | if($sort_order != 'asc') |
||
124 | { |
||
125 | $sort_order = 'desc'; |
||
126 | } |
||
127 | |||
128 | if($args->selected_group_srl) |
||
129 | { |
||
130 | $query_id = 'member.getMemberListWithinGroup'; |
||
131 | $args->sort_index = "member.".$sort_index; |
||
132 | } |
||
133 | else |
||
134 | { |
||
135 | $query_id = 'member.getMemberList'; |
||
136 | $args->sort_index = $sort_index; |
||
137 | } |
||
138 | |||
139 | $args->sort_order = $sort_order; |
||
140 | Context::set('sort_order', $sort_order); |
||
141 | // Other variables |
||
142 | $args->page = Context::get('page'); |
||
143 | $args->list_count = 40; |
||
144 | $args->page_count = 10; |
||
145 | $output = executeQuery($query_id, $args); |
||
146 | |||
147 | return $output; |
||
148 | } |
||
149 | |||
309 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.