| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 50 | static function users_security () { |
||
| 51 | $Config = Config::instance(); |
||
| 52 | $Index = Index::instance(); |
||
| 53 | $L = Language::instance(); |
||
| 54 | /** |
||
| 55 | * @var \cs\_SERVER $_SERVER |
||
| 56 | */ |
||
| 57 | $Index->apply_button = true; |
||
| 58 | $Index->content( |
||
| 59 | static::vertical_table( |
||
| 60 | [ |
||
| 61 | [ |
||
| 62 | h::info('key_expire'), |
||
| 63 | h::{'input[is=cs-input-text][type=number]'}( |
||
| 64 | [ |
||
| 65 | 'name' => 'core[key_expire]', |
||
| 66 | 'value' => $Config->core['key_expire'], |
||
| 67 | 'min' => 1 |
||
| 68 | ] |
||
| 69 | ). |
||
| 70 | $L->seconds |
||
| 71 | ], |
||
| 72 | [ |
||
| 73 | h::info('ip_black_list'), |
||
| 74 | h::{'textarea[is=cs-textarea][autosize]'}( |
||
| 75 | $Config->core['ip_black_list'], |
||
| 76 | [ |
||
| 77 | 'name' => 'core[ip_black_list]' |
||
| 78 | ] |
||
| 79 | ) |
||
| 80 | ], |
||
| 81 | [ |
||
| 82 | h::info('ip_admin_list_only'), |
||
| 83 | h::radio( |
||
| 84 | [ |
||
| 85 | 'name' => 'core[ip_admin_list_only]', |
||
| 86 | 'checked' => $Config->core['ip_admin_list_only'], |
||
| 87 | 'value' => [0, 1], |
||
| 88 | 'in' => [$L->off, $L->on] |
||
| 89 | ] |
||
| 90 | ) |
||
| 91 | ], |
||
| 92 | [ |
||
| 93 | h::info('ip_admin_list'), |
||
| 94 | h::{'textarea[is=cs-textarea][autosize]'}( |
||
| 95 | $Config->core['ip_admin_list'], |
||
| 96 | [ |
||
| 97 | 'name' => 'core[ip_admin_list]' |
||
| 98 | ] |
||
| 99 | ). |
||
| 100 | h::br(). |
||
| 101 | $L->current_ip.': '.h::b($_SERVER->ip) |
||
| 102 | ] |
||
| 103 | ] |
||
| 104 | ) |
||
| 105 | ); |
||
| 106 | } |
||
| 107 | static function users_users () { |
||
| 202 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: