| Conditions | 2 |
| Paths | 2 |
| Total Lines | 72 |
| Code Lines | 47 |
| 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); |
||
| 51 | public function __construct($target) |
||
| 52 | { |
||
| 53 | $this->helper = $target->helper; |
||
| 54 | $this->targetObject = $target; |
||
| 55 | $title = $this->targetObject->isNew() ? \AM_SUICO_VISITORS_ADD : \AM_SUICO_VISITORS_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 | 'visit_id', |
||
| 61 | $this->targetObject->getVar( |
||
| 62 | 'visit_id' |
||
| 63 | ) |
||
| 64 | ); |
||
| 65 | $this->addElement($hidden); |
||
| 66 | unset($hidden); |
||
| 67 | // Cod_visit |
||
| 68 | $this->addElement( |
||
| 69 | new XoopsFormLabel(\AM_SUICO_VISITORS_VISIT_ID, $this->targetObject->getVar('visit_id'), 'visit_id') |
||
| 70 | ); |
||
| 71 | // Uid_owner |
||
| 72 | $this->addElement( |
||
| 73 | new XoopsFormSelectUser( |
||
| 74 | \AM_SUICO_VISITORS_UID_OWNER, |
||
| 75 | 'uid_owner', |
||
| 76 | false, |
||
| 77 | $this->targetObject->getVar( |
||
| 78 | 'uid_owner' |
||
| 79 | ), |
||
| 80 | 1, |
||
| 81 | false |
||
| 82 | ), |
||
| 83 | false |
||
| 84 | ); |
||
| 85 | // Uid_visitor |
||
| 86 | $this->addElement( |
||
| 87 | new XoopsFormSelectUser( |
||
| 88 | \AM_SUICO_VISITORS_UID_VISITOR, |
||
| 89 | 'uid_visitor', |
||
| 90 | false, |
||
| 91 | $this->targetObject->getVar( |
||
| 92 | 'uid_visitor' |
||
| 93 | ), |
||
| 94 | 1, |
||
| 95 | false |
||
| 96 | ), |
||
| 97 | false |
||
| 98 | ); |
||
| 99 | // Uname_visitor |
||
| 100 | $this->addElement( |
||
| 101 | new XoopsFormText( |
||
| 102 | \AM_SUICO_VISITORS_UNAME_VISITOR, |
||
| 103 | 'uname_visitor', |
||
| 104 | 50, |
||
| 105 | 255, |
||
| 106 | $this->targetObject->getVar( |
||
| 107 | 'uname_visitor' |
||
| 108 | ) |
||
| 109 | ), |
||
| 110 | false |
||
| 111 | ); |
||
| 112 | // Datetime |
||
| 113 | $this->addElement( |
||
| 114 | new XoopsFormTextDateSelect( |
||
| 115 | \AM_SUICO_VISITORS_DATETIME, |
||
| 116 | 'date_visited', |
||
| 117 | 0, |
||
| 118 | \formatTimestamp($this->targetObject->getVar('date_visited'), 's') |
||
|
|
|||
| 119 | ) |
||
| 120 | ); |
||
| 121 | $this->addElement(new XoopsFormHidden('op', 'save')); |
||
| 122 | $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
| 123 | } |
||
| 125 |