| Conditions | 9 |
| Paths | 24 |
| Total Lines | 91 |
| Code Lines | 37 |
| 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->getColumnsSize(); |
||
| 57 | |||
| 58 | if (empty($size)) { |
||
| 59 | $sizeTemp = $this->getInputSize(); |
||
| 60 | if (empty($size)) { |
||
| 61 | $sizeTemp = 8; |
||
| 62 | } |
||
| 63 | $size = [2, $sizeTemp, 2]; |
||
| 64 | } else { |
||
| 65 | if (is_array($size)) { |
||
| 66 | if (count($size) != 3) { |
||
| 67 | $sizeTemp = $this->getInputSize(); |
||
| 68 | if (empty($size)) { |
||
| 69 | $sizeTemp = 8; |
||
| 70 | } |
||
| 71 | $size = [2, $sizeTemp, 2]; |
||
| 72 | } |
||
| 73 | // else just keep the $size array as received |
||
| 74 | } else { |
||
| 75 | $size = [2, (int) $size, 2]; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | $id = $this->getAttribute('id'); |
||
| 80 | |||
| 81 | switch ($layout) { |
||
| 82 | case FormValidator::LAYOUT_INLINE: |
||
| 83 | return ' |
||
| 84 | <div class="form-group {error_class}"> |
||
| 85 | <label {label-for} > |
||
| 86 | <!-- BEGIN required --><span class="form_required">*</span><!-- END required --> |
||
| 87 | {label} |
||
| 88 | </label> |
||
| 89 | {element} |
||
| 90 | </div>'; |
||
| 91 | break; |
||
|
|
|||
| 92 | case FormValidator::LAYOUT_HORIZONTAL: |
||
| 93 | return ' |
||
| 94 | <span id="'.$id.'_date_time_wrapper"> |
||
| 95 | <div class="form-group {error_class}"> |
||
| 96 | <label {label-for} class="col-sm-'.$size[0].' control-label" > |
||
| 97 | <!-- BEGIN required --><span class="form_required">*</span><!-- END required --> |
||
| 98 | {label} |
||
| 99 | </label> |
||
| 100 | <div class="col-sm-'.$size[1].'"> |
||
| 101 | {icon} |
||
| 102 | {element} |
||
| 103 | |||
| 104 | <!-- BEGIN label_2 --> |
||
| 105 | <p class="help-block">{label_2}</p> |
||
| 106 | <!-- END label_2 --> |
||
| 107 | |||
| 108 | <!-- BEGIN error --> |
||
| 109 | <span class="help-inline help-block">{error}</span> |
||
| 110 | <!-- END error --> |
||
| 111 | </div> |
||
| 112 | <div class="col-sm-'.$size[2].'"> |
||
| 113 | <!-- BEGIN label_3 --> |
||
| 114 | {label_3} |
||
| 115 | <!-- END label_3 --> |
||
| 116 | </div> |
||
| 117 | </div> |
||
| 118 | <div class="form-group {error_class}"> |
||
| 119 | <label class="col-sm-'.$size[0].' control-label" > |
||
| 120 | <!-- BEGIN required --><span class="form_required">*</span><!-- END required --> |
||
| 121 | '.get_lang('Hour').' |
||
| 122 | </label> |
||
| 123 | <div class="col-sm-'.$size[1].'"> |
||
| 124 | <div class="input-group"> |
||
| 125 | <p id="'.$id.'_time_range"> |
||
| 126 | <input type="text" id="'.$id.'_time_range_start" name="'.$id.'_time_range_start" class="time start" autocomplete="off"> |
||
| 127 | '.get_lang('To').' |
||
| 128 | <input type="text" id="'.$id.'_time_range_end" name="'.$id.'_time_range_end" class="time end " autocomplete="off"> |
||
| 129 | </p> |
||
| 130 | </div> |
||
| 131 | </div> |
||
| 132 | </div> |
||
| 133 | </span> |
||
| 134 | '; |
||
| 135 | break; |
||
| 136 | case FormValidator::LAYOUT_BOX_NO_LABEL: |
||
| 137 | return ' |
||
| 138 | <label {label-for}>{label}</label> |
||
| 139 | <div class="input-group"> |
||
| 140 | |||
| 141 | {icon} |
||
| 142 | {element} |
||
| 143 | </div>'; |
||
| 144 | break; |
||
| 145 | } |
||
| 262 |
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.