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