| Conditions | 2 |
| Paths | 2 |
| Total Lines | 98 |
| Code Lines | 65 |
| 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_VIDEO_ADD : \AM_SUICO_VIDEO_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 | 'video_id', |
||
| 61 | $this->targetObject->getVar( |
||
| 62 | 'video_id' |
||
| 63 | ) |
||
| 64 | ); |
||
| 65 | $this->addElement($hidden); |
||
| 66 | unset($hidden); |
||
| 67 | // Video_id |
||
| 68 | $this->addElement( |
||
| 69 | new XoopsFormLabel(\AM_SUICO_VIDEO_VIDEO_ID, $this->targetObject->getVar('video_id'), 'video_id') |
||
| 70 | ); |
||
| 71 | // Uid_owner |
||
| 72 | $this->addElement( |
||
| 73 | new XoopsFormSelectUser( |
||
| 74 | \AM_SUICO_VIDEO_UID_OWNER, |
||
| 75 | 'uid_owner', |
||
| 76 | false, |
||
| 77 | $this->targetObject->getVar( |
||
| 78 | 'uid_owner' |
||
| 79 | ), |
||
| 80 | 1, |
||
| 81 | false |
||
| 82 | ), |
||
| 83 | false |
||
| 84 | ); |
||
| 85 | // Video Title |
||
| 86 | $this->addElement( |
||
| 87 | new XoopsFormText( |
||
| 88 | \AM_SUICO_VIDEO_TITLE, |
||
| 89 | 'video_title', |
||
| 90 | 50, |
||
| 91 | 255, |
||
| 92 | $this->targetObject->getVar( |
||
| 93 | 'video_title' |
||
| 94 | ) |
||
| 95 | ), |
||
| 96 | false |
||
| 97 | ); |
||
| 98 | // Video_desc |
||
| 99 | $this->addElement( |
||
| 100 | new XoopsFormTextArea( |
||
| 101 | \AM_SUICO_VIDEO_VIDEO_DESC, |
||
| 102 | 'video_desc', |
||
| 103 | $this->targetObject->getVar( |
||
| 104 | 'video_desc' |
||
| 105 | ), |
||
| 106 | 4, |
||
| 107 | 47 |
||
| 108 | ), |
||
| 109 | false |
||
| 110 | ); |
||
| 111 | // Youtube_code |
||
| 112 | $this->addElement( |
||
| 113 | new XoopsFormText( |
||
| 114 | \AM_SUICO_VIDEO_YOUTUBE_CODE, |
||
| 115 | 'youtube_code', |
||
| 116 | 50, |
||
| 117 | 255, |
||
| 118 | $this->targetObject->getVar( |
||
| 119 | 'youtube_code' |
||
| 120 | ) |
||
| 121 | ), |
||
| 122 | false |
||
| 123 | ); |
||
| 124 | // Main_video |
||
| 125 | $this->addElement( |
||
| 126 | new XoopsFormText( |
||
| 127 | \AM_SUICO_VIDEO_MAIN_VIDEO, |
||
| 128 | 'featured_video', |
||
| 129 | 50, |
||
| 130 | 255, |
||
| 131 | $this->targetObject->getVar( |
||
| 132 | 'featured_video' |
||
| 133 | ) |
||
| 134 | ), |
||
| 135 | false |
||
| 136 | ); |
||
| 137 | // Data_creation |
||
| 138 | $this->addElement(new \XoopsFormTextDateSelect(\AM_SUICO_VIDEO_DATE_CREATED, 'date_created', 0, \formatTimestamp($this->targetObject->getVar('date_created'), 's'))); |
||
|
|
|||
| 139 | $this->addElement( |
||
| 140 | new \XoopsFormTextDateSelect( |
||
| 141 | \AM_SUICO_VIDEO_DATE_UPDATED, |
||
| 142 | 'date_updated', |
||
| 143 | 0, |
||
| 144 | \formatTimestamp($this->targetObject->getVar('date_updated'), 's') |
||
| 145 | ) |
||
| 146 | ); |
||
| 147 | $this->addElement(new XoopsFormHidden('op', 'save')); |
||
| 148 | $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
||
| 149 | } |
||
| 151 |