| Conditions | 2 |
| Paths | 1 |
| Total Lines | 73 |
| Code Lines | 42 |
| 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 |
||
| 140 | public static function edit_page ($Request) { |
||
| 141 | $L = new Prefix('static_pages_'); |
||
| 142 | $id = (int)$Request->route[1]; |
||
| 143 | $data = Pages::instance()->get($id); |
||
| 144 | $textarea = h::{'textarea[is=cs-textarea][autosize][name=content]'}($data['content']); |
||
| 145 | Page::instance() |
||
| 146 | ->title($L->editing_of_page($data['title'])) |
||
| 147 | ->content( |
||
| 148 | h::{'form[is=cs-form][action=admin/Static_pages]'}( |
||
| 149 | h::h2( |
||
| 150 | $L->editing_of_page($data['title']) |
||
| 151 | ). |
||
| 152 | h::{'table.cs-table[center] tr'}( |
||
| 153 | h::th( |
||
| 154 | $L->category, |
||
| 155 | $L->page_title, |
||
| 156 | h::info('static_pages_page_path'), |
||
| 157 | h::info('static_pages_page_interface') |
||
| 158 | ), |
||
| 159 | h::td( |
||
| 160 | h::{'select[is=cs-select][full-width][name=category][size=5]'}( |
||
| 161 | static::get_categories_list(), |
||
| 162 | [ |
||
| 163 | 'selected' => $data['category'] |
||
| 164 | ] |
||
| 165 | ), |
||
| 166 | h::{'input[is=cs-input-text][full-width][name=title]'}( |
||
| 167 | [ |
||
| 168 | 'value' => $data['title'] |
||
| 169 | ] |
||
| 170 | ), |
||
| 171 | h::{'input[is=cs-input-text][full-width][name=path]'}( |
||
| 172 | [ |
||
| 173 | 'value' => $data['path'] |
||
| 174 | ] |
||
| 175 | ), |
||
| 176 | h::{'div radio[name=interface]'}( |
||
| 177 | [ |
||
| 178 | 'checked' => $data['interface'], |
||
| 179 | 'value' => [0, 1], |
||
| 180 | 'in' => [$L->off, $L->on] |
||
| 181 | ] |
||
| 182 | ) |
||
| 183 | ) |
||
| 184 | ). |
||
| 185 | h::{'table.cs-table[center] tr'}( |
||
| 186 | h::th($L->content), |
||
| 187 | h::td( |
||
| 188 | $data['interface'] ? h::cs_editor($textarea) : $textarea |
||
| 189 | ) |
||
| 190 | ). |
||
| 191 | h::{'input[type=hidden][name=id]'}( |
||
| 192 | [ |
||
| 193 | 'value' => $id |
||
| 194 | ] |
||
| 195 | ). |
||
| 196 | h::p( |
||
| 197 | h::{'button[is=cs-button][type=submit][name=mode][value=edit_page]'}( |
||
| 198 | $L->save, |
||
| 199 | [ |
||
| 200 | 'tooltip' => $L->save_info |
||
| 201 | ] |
||
| 202 | ). |
||
| 203 | h::{'button[is=cs-button][type=button]'}( |
||
| 204 | $L->cancel, |
||
| 205 | [ |
||
| 206 | 'onclick' => 'history.go(-1);' |
||
| 207 | ] |
||
| 208 | ) |
||
| 209 | ) |
||
| 210 | ) |
||
| 211 | ); |
||
| 212 | } |
||
| 213 | /** |
||
| 247 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.