| Conditions | 2 |
| Paths | 2 |
| Total Lines | 101 |
| Code Lines | 69 |
| 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 declare(strict_types=1); |
||
| 50 | public function __construct($target) |
||
| 51 | { |
||
| 52 | $this->helper = $target->helper; |
||
| 53 | $this->targetObject = $target; |
||
| 54 | $title = $this->targetObject->isNew() ? \AM_SUICO_SUSPENSIONS_ADD : |
||
| 55 | \AM_SUICO_SUSPENSIONS_EDIT; |
||
| 56 | parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); |
||
| 57 | $this->setExtra('enctype="multipart/form-data"'); |
||
| 58 | //include ID field, it's needed so the module knows if it is a new form or an edited form |
||
| 59 | $hidden = new XoopsFormHidden( |
||
| 60 | 'uid', |
||
| 61 | $this->targetObject->getVar( |
||
| 62 | 'uid' |
||
| 63 | ) |
||
| 64 | ); |
||
| 65 | $this->addElement($hidden); |
||
| 66 | unset($hidden); |
||
| 67 | // Uid |
||
| 68 | $this->addElement( |
||
| 69 | new XoopsFormLabel(\AM_SUICO_SUSPENSIONS_UID, $this->targetObject->getVar('uid'), 'uid') |
||
| 70 | ); |
||
| 71 | // Old_pass |
||
| 72 | $this->addElement( |
||
| 73 | new XoopsFormText( |
||
| 74 | \AM_SUICO_SUSPENSIONS_OLD_PASS, |
||
| 75 | 'old_pass', |
||
| 76 | 50, |
||
| 77 | 255, |
||
| 78 | $this->targetObject->getVar( |
||
| 79 | 'old_pass' |
||
| 80 | ) |
||
| 81 | ), |
||
| 82 | false |
||
| 83 | ); |
||
| 84 | // Old_email |
||
| 85 | $this->addElement( |
||
| 86 | new XoopsFormText( |
||
| 87 | \AM_SUICO_SUSPENSIONS_OLD_EMAIL, |
||
| 88 | 'old_email', |
||
| 89 | 50, |
||
| 90 | 255, |
||
| 91 | $this->targetObject->getVar( |
||
| 92 | 'old_email' |
||
| 93 | ) |
||
| 94 | ), |
||
| 95 | false |
||
| 96 | ); |
||
| 97 | // Old_signature |
||
| 98 | $this->addElement( |
||
| 99 | new XoopsFormTextArea( |
||
| 100 | \AM_SUICO_SUSPENSIONS_OLD_SIGNATURE, |
||
| 101 | 'old_signature', |
||
| 102 | $this->targetObject->getVar( |
||
| 103 | 'old_signature' |
||
| 104 | ), |
||
| 105 | 4, |
||
| 106 | 47 |
||
| 107 | ), |
||
| 108 | false |
||
| 109 | ); |
||
| 110 | // Suspension_time |
||
| 111 | $this->addElement( |
||
| 112 | new XoopsFormText( |
||
| 113 | \AM_SUICO_SUSPENSIONS_SUSPENSION_TIME, |
||
| 114 | 'suspension_time', |
||
| 115 | 50, |
||
| 116 | 255, |
||
| 117 | $this->targetObject->getVar( |
||
| 118 | 'suspension_time' |
||
| 119 | ) |
||
| 120 | ), |
||
| 121 | false |
||
| 122 | ); |
||
| 123 | // Old_enc_type |
||
| 124 | $this->addElement( |
||
| 125 | new XoopsFormText( |
||
| 126 | \AM_SUICO_SUSPENSIONS_OLD_ENC_TYPE, |
||
| 127 | 'old_enc_type', |
||
| 128 | 50, |
||
| 129 | 255, |
||
| 130 | $this->targetObject->getVar( |
||
| 131 | 'old_enc_type' |
||
| 132 | ) |
||
| 133 | ), |
||
| 134 | false |
||
| 135 | ); |
||
| 136 | // Old_pass_expired |
||
| 137 | $this->addElement( |
||
| 138 | new XoopsFormText( |
||
| 139 | \AM_SUICO_SUSPENSIONS_OLD_PASS_EXPIRED, |
||
| 140 | 'old_pass_expired', |
||
| 141 | 50, |
||
| 142 | 255, |
||
| 143 | $this->targetObject->getVar( |
||
| 144 | 'old_pass_expired' |
||
| 145 | ) |
||
| 146 | ), |
||
| 147 | false |
||
| 148 | ); |
||
| 149 | $this->addElement(new XoopsFormHidden('op', 'save')); |
||
| 150 | $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
| 151 | } |
||
| 153 |