| Conditions | 3 |
| Paths | 2 |
| Total Lines | 51 |
| 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 |
||
| 24 | public function show() |
||
| 25 | { |
||
| 26 | global $lang; |
||
| 27 | global $conf; |
||
| 28 | global $INPUT; |
||
| 29 | |||
| 30 | $token = preg_replace('/[^a-f0-9]+/', '', $INPUT->str('pwauth')); |
||
| 31 | |||
| 32 | // print intro |
||
| 33 | print p_locale_xhtml('resetpwd'); |
||
| 34 | print '<div class="centeralign">'.DOKU_LF; |
||
| 35 | |||
| 36 | if (!$conf['autopasswd'] && $token) { |
||
| 37 | // create the form |
||
| 38 | $form = new Form(['id' => 'dw__resendpwd']); |
||
| 39 | $form->addTagOpen('div')->addClass('no'); |
||
| 40 | $form->addFieldsetOpen($lang['btn_resendpwd']); |
||
| 41 | $form->setHiddenField('token', $token); |
||
| 42 | $form->setHiddenField('do', 'resendpwd'); |
||
| 43 | $input = $form->addPasswordInput('pass', $lang['pass'])->attr('size', '50')->addClass('edit'); |
||
| 44 | $input->getLabel()->attr('class', 'block'); |
||
| 45 | $form->addHTML("<br>\n"); |
||
| 46 | $input = $form->addPasswordInput('passchk', $lang['passchk'])->attr('size', '50')->addClass('edit'); |
||
| 47 | $input->getLabel()->attr('class', 'block'); |
||
| 48 | $form->addHTML("<br>\n"); |
||
| 49 | $form->addButton('', $lang['btn_resendpwd'])->attrs(['type' => 'submit']); |
||
| 50 | $form->addFieldsetClose(); |
||
| 51 | $form->addTagClose('div'); |
||
| 52 | } else { |
||
| 53 | // create the form |
||
| 54 | $form = new Form(['id' => 'dw__resendpwd']); |
||
| 55 | $form->addTagOpen('div')->addClass('no'); |
||
| 56 | $form->addFieldsetOpen($lang['btn_resendpwd']); |
||
| 57 | $form->setHiddenField('do', 'resendpwd'); |
||
| 58 | $form->setHiddenField('save', '1'); |
||
| 59 | $form->addHTML("<br>\n"); |
||
| 60 | $input = $form->addTextInput('login', $lang['user'])->addClass('edit') |
||
| 61 | ->val($INPUT->str('login')); |
||
| 62 | $input->getLabel()->attr('class', 'block'); |
||
| 63 | $form->addHTML("<br>\n"); |
||
| 64 | $form->addHTML("<br>\n"); |
||
| 65 | $form->addButton('', $lang['btn_resendpwd'])->attrs(['type' => 'submit']); |
||
| 66 | $form->addFieldsetClose(); |
||
| 67 | $form->addTagClose('div'); |
||
| 68 | } |
||
| 69 | |||
| 70 | // emit HTML_RESENDPWDFORM_OUTPUT event, print the form |
||
| 71 | Event::createAndTrigger('HTML_RESENDPWDFORM_OUTPUT', $form, 'html_form_output', false); |
||
| 72 | |||
| 73 | print '</div>'.DOKU_LF; |
||
| 74 | } |
||
| 75 | |||
| 77 |