| Conditions | 4 |
| Paths | 4 |
| Total Lines | 69 |
| Code Lines | 23 |
| 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 |
||
| 54 | public function getTemplate($layout) |
||
| 55 | { |
||
| 56 | $size = $this->calculateSize(); |
||
| 57 | $id = $this->getAttribute('id'); |
||
| 58 | |||
| 59 | switch ($layout) { |
||
| 60 | case FormValidator::LAYOUT_INLINE: |
||
| 61 | return ' |
||
| 62 | <div class="form-group {error_class}"> |
||
| 63 | <label {label-for} > |
||
| 64 | <!-- BEGIN required --><span class="form_required">*</span><!-- END required --> |
||
| 65 | {label} |
||
| 66 | </label> |
||
| 67 | {element} |
||
| 68 | </div>'; |
||
| 69 | break; |
||
|
|
|||
| 70 | case FormValidator::LAYOUT_HORIZONTAL: |
||
| 71 | return ' |
||
| 72 | <span id="'.$id.'_date_time_wrapper"> |
||
| 73 | <div class="form-group {error_class}"> |
||
| 74 | <label {label-for} class="col-sm-'.$size[0].' control-label" > |
||
| 75 | <!-- BEGIN required --><span class="form_required">*</span><!-- END required --> |
||
| 76 | {label} |
||
| 77 | </label> |
||
| 78 | <div class="col-sm-'.$size[1].'"> |
||
| 79 | {icon} |
||
| 80 | {element} |
||
| 81 | |||
| 82 | <!-- BEGIN label_2 --> |
||
| 83 | <p class="help-block">{label_2}</p> |
||
| 84 | <!-- END label_2 --> |
||
| 85 | |||
| 86 | <!-- BEGIN error --> |
||
| 87 | <span class="help-inline help-block">{error}</span> |
||
| 88 | <!-- END error --> |
||
| 89 | </div> |
||
| 90 | <div class="col-sm-'.$size[2].'"> |
||
| 91 | <!-- BEGIN label_3 --> |
||
| 92 | {label_3} |
||
| 93 | <!-- END label_3 --> |
||
| 94 | </div> |
||
| 95 | </div> |
||
| 96 | <div class="form-group {error_class}"> |
||
| 97 | <label class="col-sm-'.$size[0].' control-label" > |
||
| 98 | <!-- BEGIN required --><span class="form_required">*</span><!-- END required --> |
||
| 99 | '.get_lang('Hour').' |
||
| 100 | </label> |
||
| 101 | <div class="col-sm-'.$size[1].'"> |
||
| 102 | <div class="input-group"> |
||
| 103 | <p id="'.$id.'_time_range"> |
||
| 104 | <input type="text" id="'.$id.'_time_range_start" name="'.$id.'_time_range_start" class="time start" autocomplete="off"> |
||
| 105 | '.get_lang('To').' |
||
| 106 | <input type="text" id="'.$id.'_time_range_end" name="'.$id.'_time_range_end" class="time end " autocomplete="off"> |
||
| 107 | </p> |
||
| 108 | </div> |
||
| 109 | </div> |
||
| 110 | </div> |
||
| 111 | </span> |
||
| 112 | '; |
||
| 113 | break; |
||
| 114 | case FormValidator::LAYOUT_BOX_NO_LABEL: |
||
| 115 | return ' |
||
| 116 | <label {label-for}>{label}</label> |
||
| 117 | <div class="input-group"> |
||
| 118 | |||
| 119 | {icon} |
||
| 120 | {element} |
||
| 121 | </div>'; |
||
| 122 | break; |
||
| 123 | } |
||
| 240 |
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.