| Conditions | 4 |
| Paths | 1 |
| Total Lines | 92 |
| Code Lines | 49 |
| 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 |
||
| 36 | static function users_mail () { |
||
| 37 | $Config = Config::instance(); |
||
| 38 | $Index = Index::instance(); |
||
| 39 | $L = Language::instance(); |
||
| 40 | $Index->apply_button = true; |
||
| 41 | $Index->content( |
||
| 42 | static::vertical_table( |
||
| 43 | [ |
||
| 44 | [ |
||
| 45 | h::info('smtp'), |
||
| 46 | h::radio( |
||
| 47 | [ |
||
| 48 | 'name' => 'core[smtp]', |
||
| 49 | 'checked' => $Config->core['smtp'], |
||
| 50 | 'value' => [0, 1], |
||
| 51 | 'in' => [$L->off, $L->on], |
||
| 52 | 'OnClick' => ["$('#smtp_form').parent().parent().children().hide();", "$('#smtp_form').parent().parent().children().show();"] |
||
| 53 | ] |
||
| 54 | ) |
||
| 55 | ], |
||
| 56 | [ |
||
| 57 | [ |
||
| 58 | '', |
||
| 59 | h::{'table#smtp_form tr'}( |
||
| 60 | h::td( |
||
| 61 | static::core_input('smtp_host') |
||
| 62 | ), |
||
| 63 | h::td( |
||
| 64 | static::core_input('smtp_port') |
||
| 65 | ), |
||
| 66 | h::td( |
||
| 67 | [ |
||
| 68 | h::info('smtp_secure'), |
||
| 69 | h::radio( |
||
| 70 | [ |
||
| 71 | 'name' => 'core[smtp_secure]', |
||
| 72 | 'checked' => $Config->core['smtp_secure'], |
||
| 73 | 'value' => ['', 'ssl', 'tls'], |
||
| 74 | 'in' => [$L->off, 'SSL', 'TLS'] |
||
| 75 | ] |
||
| 76 | ) |
||
| 77 | ] |
||
| 78 | ), |
||
| 79 | h::td( |
||
| 80 | [ |
||
| 81 | $L->smtp_auth, |
||
| 82 | h::radio( |
||
| 83 | [ |
||
| 84 | 'name' => 'core[smtp_auth]', |
||
| 85 | 'checked' => $Config->core['smtp_auth'], |
||
| 86 | 'value' => [0, 1], |
||
| 87 | 'in' => [$L->off, $L->on], |
||
| 88 | 'OnClick' => ["$('#smtp_user, #smtp_password').hide();", "$('#smtp_user, #smtp_password').show();"] |
||
| 89 | ] |
||
| 90 | ) |
||
| 91 | ] |
||
| 92 | ), |
||
| 93 | [ |
||
| 94 | h::td( |
||
| 95 | static::core_input('smtp_user') |
||
| 96 | ), |
||
| 97 | [ |
||
| 98 | 'style' => (!$Config->core['smtp_auth'] ? 'display: none;' : '').' padding-left: 20px;', |
||
| 99 | 'id' => 'smtp_user' |
||
| 100 | ] |
||
| 101 | ], |
||
| 102 | [ |
||
| 103 | h::td( |
||
| 104 | static::core_input('smtp_password') |
||
| 105 | ), |
||
| 106 | [ |
||
| 107 | 'style' => !$Config->core['smtp_auth'] ? 'display: none;' : '', |
||
| 108 | 'id' => 'smtp_password' |
||
| 109 | ] |
||
| 110 | ] |
||
| 111 | ) |
||
| 112 | ], |
||
| 113 | [ |
||
| 114 | 'style' => !$Config->core['smtp'] ? 'display: none; ' : '' |
||
| 115 | ] |
||
| 116 | ], |
||
| 117 | static::core_input('mail_from'), |
||
| 118 | static::core_input('mail_from_name'), |
||
| 119 | static::core_textarea('mail_signature', 'cs-editor-simple'), |
||
| 120 | [ |
||
| 121 | '', |
||
| 122 | h::{'td button[is=cs-button][onclick=cs.test_email_sending()]'}($L->test_email_sending) |
||
| 123 | ] |
||
| 124 | ] |
||
| 125 | ) |
||
| 126 | ); |
||
| 127 | } |
||
| 128 | static function users_permissions () { |
||
| 287 |
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: