| Conditions | 2 |
| Paths | 2 |
| Total Lines | 95 |
| Code Lines | 61 |
| 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); |
||
| 50 | public function __construct($target) |
||
| 51 | { |
||
| 52 | $this->helper = $target->helper; |
||
| 53 | $this->targetObject = $target; |
||
| 54 | $title = $this->targetObject->isNew() ? \AM_SUICO_FRIENDSHIP_ADD : |
||
| 55 | \AM_SUICO_FRIENDSHIP_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 | 'friendship_id', |
||
| 61 | $this->targetObject->getVar( |
||
| 62 | 'friendship_id' |
||
| 63 | ) |
||
| 64 | ); |
||
| 65 | $this->addElement($hidden); |
||
| 66 | unset($hidden); |
||
| 67 | // Friendship_id |
||
| 68 | $this->addElement( |
||
| 69 | new XoopsFormLabel( |
||
| 70 | \AM_SUICO_FRIENDSHIP_FRIENDSHIP_ID, |
||
| 71 | $this->targetObject->getVar( |
||
| 72 | 'friendship_id' |
||
| 73 | ), |
||
| 74 | 'friendship_id' |
||
| 75 | ) |
||
| 76 | ); |
||
| 77 | // Friend1_uid |
||
| 78 | $this->addElement( |
||
| 79 | new XoopsFormSelectUser( |
||
| 80 | \AM_SUICO_FRIENDSHIP_FRIEND1_UID, |
||
| 81 | 'friend1_uid', |
||
| 82 | false, |
||
| 83 | $this->targetObject->getVar('friend1_uid'), |
||
| 84 | 1, |
||
| 85 | false |
||
| 86 | ), |
||
| 87 | false |
||
| 88 | ); |
||
| 89 | // Friend2_uid |
||
| 90 | $this->addElement( |
||
| 91 | new XoopsFormSelectUser( |
||
| 92 | \AM_SUICO_FRIENDSHIP_FRIEND2_UID, |
||
| 93 | 'friend2_uid', |
||
| 94 | false, |
||
| 95 | $this->targetObject->getVar('friend2_uid'), |
||
| 96 | 1, |
||
| 97 | false |
||
| 98 | ), |
||
| 99 | false |
||
| 100 | ); |
||
| 101 | // Level |
||
| 102 | $this->addElement( |
||
| 103 | new XoopsFormText(\AM_SUICO_FRIENDSHIP_LEVEL, 'level', 50, 255, $this->targetObject->getVar('level')), |
||
| 104 | false |
||
| 105 | ); |
||
| 106 | // Hot |
||
| 107 | $this->addElement( |
||
| 108 | new XoopsFormText(\AM_SUICO_FRIENDSHIP_HOT, 'hot', 50, 255, $this->targetObject->getVar('hot')), |
||
| 109 | false |
||
| 110 | ); |
||
| 111 | // Trust |
||
| 112 | $this->addElement( |
||
| 113 | new XoopsFormText(\AM_SUICO_FRIENDSHIP_TRUST, 'trust', 50, 255, $this->targetObject->getVar('trust')), |
||
| 114 | false |
||
| 115 | ); |
||
| 116 | // Cool |
||
| 117 | $this->addElement( |
||
| 118 | new XoopsFormText(\AM_SUICO_FRIENDSHIP_COOL, 'cool', 50, 255, $this->targetObject->getVar('cool')), |
||
| 119 | false |
||
| 120 | ); |
||
| 121 | // Fan |
||
| 122 | $this->addElement( |
||
| 123 | new XoopsFormText(\AM_SUICO_FRIENDSHIP_FAN, 'fan', 50, 255, $this->targetObject->getVar('fan')), |
||
| 124 | false |
||
| 125 | ); |
||
| 126 | // Data_creation |
||
| 127 | $this->addElement( |
||
| 128 | new \XoopsFormTextDateSelect( |
||
| 129 | \AM_SUICO_FRIENDSHIP_DATE_CREATED, |
||
| 130 | 'date_created', |
||
| 131 | 0, |
||
| 132 | \formatTimestamp($this->targetObject->getVar('date_created'), 's') |
||
|
|
|||
| 133 | ) |
||
| 134 | ); |
||
| 135 | $this->addElement( |
||
| 136 | new \XoopsFormTextDateSelect( |
||
| 137 | \AM_SUICO_FRIENDSHIP_DATE_UPDATED, |
||
| 138 | 'date_updated', |
||
| 139 | 0, |
||
| 140 | \formatTimestamp($this->targetObject->getVar('date_updated'), 's') |
||
| 141 | ) |
||
| 142 | ); |
||
| 143 | $this->addElement(new XoopsFormHidden('op', 'save')); |
||
| 144 | $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
| 145 | } |
||
| 147 |