| Conditions | 13 |
| Paths | 304 |
| Total Lines | 50 |
| Code Lines | 28 |
| 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 |
||
| 47 | function getLoggedMembers($args) |
||
| 48 | { |
||
| 49 | if(!$args->site_srl) |
||
| 50 | { |
||
| 51 | $site_module_info = Context::get('site_module_info'); |
||
| 52 | $args->site_srl = (int)$site_module_info->site_srl; |
||
| 53 | } |
||
| 54 | if(!$args->list_count) $args->list_count = 20; |
||
| 55 | if(!$args->page) $args->page = 1; |
||
| 56 | if(!$args->period_time) $args->period_time = 3; |
||
| 57 | $args->last_update = date("YmdHis", $_SERVER['REQUEST_TIME'] - $args->period_time*60); |
||
| 58 | |||
| 59 | $output = executeQueryArray('session.getLoggedMembers', $args); |
||
| 60 | if(!$output->toBool()) return $output; |
||
| 61 | |||
| 62 | $member_srls = array(); |
||
| 63 | $member_keys = array(); |
||
| 64 | if(count($output->data)) |
||
| 65 | { |
||
| 66 | foreach($output->data as $key => $val) |
||
| 67 | { |
||
| 68 | $member_srls[$key] = $val->member_srl; |
||
| 69 | $member_keys[$val->member_srl] = $key; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | if(Context::get('is_logged')) |
||
| 74 | { |
||
| 75 | $logged_info = Context::get('logged_info'); |
||
| 76 | if(!in_array($logged_info->member_srl, $member_srls)) |
||
| 77 | { |
||
| 78 | $member_srls[0] = $logged_info->member_srl; |
||
| 79 | $member_keys[$logged_info->member_srl] = 0; |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 83 | if(!count($member_srls)) return $output; |
||
| 84 | |||
| 85 | $member_args->member_srl = implode(',',$member_srls); |
||
|
|
|||
| 86 | $member_output = executeQueryArray('member.getMembers', $member_args); |
||
| 87 | if($member_output->data) |
||
| 88 | { |
||
| 89 | foreach($member_output->data as $key => $val) |
||
| 90 | { |
||
| 91 | $output->data[$member_keys[$val->member_srl]] = $val; |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | return $output; |
||
| 96 | } |
||
| 97 | } |
||
| 100 |
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.