| Conditions | 2 |
| Paths | 2 |
| Total Lines | 66 |
| Code Lines | 43 |
| 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); |
||
| 49 | public function __construct($target) |
||
| 50 | { |
||
| 51 | $this->helper = $target->helper; |
||
| 52 | $this->targetObject = $target; |
||
| 53 | $title = $this->targetObject->isNew() ? \AM_SUICO_FRIENDREQUEST_ADD : |
||
| 54 | \AM_SUICO_FRIENDREQUEST_EDIT; |
||
| 55 | parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); |
||
| 56 | $this->setExtra('enctype="multipart/form-data"'); |
||
| 57 | //include ID field, it's needed so the module knows if it is a new form or an edited form |
||
| 58 | $hidden = new XoopsFormHidden( |
||
| 59 | 'friendreq_id', |
||
| 60 | $this->targetObject->getVar( |
||
| 61 | 'friendreq_id' |
||
| 62 | ) |
||
| 63 | ); |
||
| 64 | $this->addElement($hidden); |
||
| 65 | unset($hidden); |
||
| 66 | // Friendpet_id |
||
| 67 | $this->addElement( |
||
| 68 | new XoopsFormLabel( |
||
| 69 | \AM_SUICO_FRIENDREQUEST_FRIENDPET_ID, |
||
| 70 | $this->targetObject->getVar( |
||
| 71 | 'friendreq_id' |
||
| 72 | ), |
||
| 73 | 'friendreq_id' |
||
| 74 | ) |
||
| 75 | ); |
||
| 76 | // Inviting by Friend_uid |
||
| 77 | $this->addElement( |
||
| 78 | new XoopsFormSelectUser( |
||
| 79 | \AM_SUICO_FRIENDREQUEST_FRIENDREQUESTER_UID, |
||
| 80 | 'friendrequester_uid', |
||
| 81 | false, |
||
| 82 | $this->targetObject->getVar( |
||
| 83 | 'friendrequester_uid' |
||
| 84 | ), |
||
| 85 | 1, |
||
| 86 | false |
||
| 87 | ), |
||
| 88 | false |
||
| 89 | ); |
||
| 90 | // Invited Friend_uid |
||
| 91 | $this->addElement( |
||
| 92 | new XoopsFormSelectUser( |
||
| 93 | \AM_SUICO_FRIENDREQUEST_FRIENDREQUESTTO_UID, |
||
| 94 | 'friendrequestto_uid', |
||
| 95 | false, |
||
| 96 | $this->targetObject->getVar( |
||
| 97 | 'friendrequestto_uid' |
||
| 98 | ), |
||
| 99 | 1, |
||
| 100 | false |
||
| 101 | ), |
||
| 102 | false |
||
| 103 | ); |
||
| 104 | // Date_created |
||
| 105 | $this->addElement( |
||
| 106 | new \XoopsFormTextDateSelect( |
||
| 107 | \AM_SUICO_FRIENDREQUEST_DATE_CREATED, |
||
| 108 | 'date_created', |
||
| 109 | 0, |
||
| 110 | \formatTimestamp($this->targetObject->getVar('date_created'), 's') |
||
|
|
|||
| 111 | ) |
||
| 112 | ); |
||
| 113 | $this->addElement(new XoopsFormHidden('op', 'save')); |
||
| 114 | $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
| 115 | } |
||
| 117 |