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