| Conditions | 10 |
| Paths | 10 |
| Total Lines | 41 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 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 |
||
| 46 | protected static function core_input ($item, $type = 'text', $info_item = null, $disabled = false, $min = false, $max = false, $post_text = '') { |
||
| 47 | $Config = Config::instance(); |
||
| 48 | $L = Language::instance(); |
||
| 49 | if ($type != 'radio') { |
||
| 50 | switch ($item) { |
||
| 51 | default: |
||
| 52 | $value = $Config->core[$item]; |
||
| 53 | break; |
||
| 54 | case 'name': |
||
| 55 | case 'closed_title': |
||
| 56 | case 'mail_from_name': |
||
| 57 | $value = get_core_ml_text($item); |
||
| 58 | } |
||
| 59 | return [ |
||
| 60 | $info_item !== false ? h::info($info_item ?: $item) : $L->$item, |
||
| 61 | h::{'input[is=cs-input-text]'}( |
||
| 62 | [ |
||
| 63 | 'name' => "core[$item]", |
||
| 64 | 'value' => $value, |
||
| 65 | 'min' => $min, |
||
| 66 | 'max' => $max, |
||
| 67 | 'type' => $type, |
||
| 68 | ($disabled ? 'disabled' : '') |
||
| 69 | ] |
||
| 70 | ). |
||
| 71 | $post_text |
||
| 72 | ]; |
||
| 73 | } else { |
||
| 74 | return [ |
||
| 75 | $info_item !== false ? h::info($info_item ?: $item) : $L->$item, |
||
| 76 | h::radio( |
||
| 77 | [ |
||
| 78 | 'name' => "core[$item]", |
||
| 79 | 'checked' => $Config->core[$item], |
||
| 80 | 'value' => [0, 1], |
||
| 81 | 'in' => [$L->off, $L->on] |
||
| 82 | ] |
||
| 83 | ) |
||
| 84 | ]; |
||
| 85 | } |
||
| 86 | } |
||
| 87 | protected static function core_textarea ($item, $editor = null, $info_item = null) { |
||
| 124 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.