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