| Conditions | 2 |
| Paths | 2 |
| Total Lines | 57 |
| Code Lines | 33 |
| 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 |
||
| 60 | public function __construct($target) |
||
| 61 | { |
||
| 62 | $this->helper = $target->helper; |
||
| 63 | $this->targetObject = $target; |
||
| 64 | |||
| 65 | $title = $this->targetObject->isNew() ? \sprintf(\AM_YOGURT_FRIENDREQUEST_ADD) : \sprintf( |
||
| 66 | \AM_YOGURT_FRIENDREQUEST_EDIT |
||
| 67 | ); |
||
| 68 | parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); |
||
| 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 | 'friendreq_id', $this->targetObject->getVar( |
||
| 75 | 'friendreq_id' |
||
| 76 | ) |
||
| 77 | ); |
||
| 78 | $this->addElement($hidden); |
||
| 79 | unset($hidden); |
||
| 80 | |||
| 81 | // Friendpet_id |
||
| 82 | $this->addElement( |
||
| 83 | new XoopsFormLabel( |
||
| 84 | \AM_YOGURT_FRIENDREQUEST_FRIENDPET_ID, $this->targetObject->getVar( |
||
| 85 | 'friendreq_id' |
||
| 86 | ), 'friendreq_id' |
||
| 87 | ) |
||
| 88 | ); |
||
| 89 | // Inviting by Friend_uid |
||
| 90 | $this->addElement( |
||
| 91 | new XoopsFormSelectUser( |
||
| 92 | \AM_YOGURT_FRIENDREQUEST_FRIENDREQUESTER_UID, 'friendrequester_uid', false, $this->targetObject->getVar( |
||
| 93 | 'friendrequester_uid' |
||
| 94 | ), 1, false |
||
| 95 | ), |
||
| 96 | false |
||
| 97 | ); |
||
| 98 | // Invited Friend_uid |
||
| 99 | $this->addElement( |
||
| 100 | new XoopsFormSelectUser( |
||
| 101 | \AM_YOGURT_FRIENDREQUEST_FRIENDREQUESTTO_UID, 'friendrequestto_uid', false, $this->targetObject->getVar( |
||
| 102 | 'friendrequestto_uid' |
||
| 103 | ), 1, false |
||
| 104 | ), |
||
| 105 | false |
||
| 106 | ); |
||
| 107 | |||
| 108 | // Date_created |
||
| 109 | $this->addElement( |
||
| 110 | new \XoopsFormTextDateSelect( |
||
| 111 | \AM_YOGURT_FRIENDREQUEST_DATE_CREATED, 'date_created', 0, formatTimestamp($this->targetObject->getVar('date_created'), 's') |
||
|
|
|||
| 112 | ) |
||
| 113 | ); |
||
| 114 | |||
| 115 | $this->addElement(new XoopsFormHidden('op', 'save')); |
||
| 116 | $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
| 117 | } |
||
| 119 |