| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 87 | 
| Code Lines | 40 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 58 | public function __construct($target)  | 
            ||
| 59 |     { | 
            ||
| 60 | $this->helper = $target->helper;  | 
            ||
| 61 | |||
| 62 | $this->targetObject = $target;  | 
            ||
| 63 | |||
| 64 | $title = $this->targetObject->isNew() ? \sprintf(\AM_YOGURT_VIDEO_ADD) : \sprintf(\AM_YOGURT_VIDEO_EDIT);  | 
            ||
| 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 | 'video_id', $this->targetObject->getVar(  | 
            ||
| 74 | 'video_id'  | 
            ||
| 75 | )  | 
            ||
| 76 | );  | 
            ||
| 77 | |||
| 78 | $this->addElement($hidden);  | 
            ||
| 79 | |||
| 80 | unset($hidden);  | 
            ||
| 81 | |||
| 82 | // Video_id  | 
            ||
| 83 | |||
| 84 | $this->addElement(  | 
            ||
| 85 |             new XoopsFormLabel(\AM_YOGURT_VIDEO_VIDEO_ID, $this->targetObject->getVar('video_id'), 'video_id') | 
            ||
| 86 | );  | 
            ||
| 87 | |||
| 88 | // Uid_owner  | 
            ||
| 89 | |||
| 90 | $this->addElement(  | 
            ||
| 91 | new XoopsFormSelectUser(  | 
            ||
| 92 | \AM_YOGURT_VIDEO_UID_OWNER, 'uid_owner', false, $this->targetObject->getVar(  | 
            ||
| 93 | 'uid_owner'  | 
            ||
| 94 | ), 1, false  | 
            ||
| 95 | ),  | 
            ||
| 96 | false  | 
            ||
| 97 | );  | 
            ||
| 98 | |||
| 99 | // Video_desc  | 
            ||
| 100 | |||
| 101 | $this->addElement(  | 
            ||
| 102 | new XoopsFormTextArea(  | 
            ||
| 103 | \AM_YOGURT_VIDEO_VIDEO_DESC, 'video_desc', $this->targetObject->getVar(  | 
            ||
| 104 | 'video_desc'  | 
            ||
| 105 | ), 4, 47  | 
            ||
| 106 | ),  | 
            ||
| 107 | false  | 
            ||
| 108 | );  | 
            ||
| 109 | |||
| 110 | // Youtube_code  | 
            ||
| 111 | |||
| 112 | $this->addElement(  | 
            ||
| 113 | new XoopsFormText(  | 
            ||
| 114 | \AM_YOGURT_VIDEO_YOUTUBE_CODE, 'youtube_code', 50, 255, $this->targetObject->getVar(  | 
            ||
| 115 | 'youtube_code'  | 
            ||
| 116 | )  | 
            ||
| 117 | ),  | 
            ||
| 118 | false  | 
            ||
| 119 | );  | 
            ||
| 120 | |||
| 121 | // Main_video  | 
            ||
| 122 | |||
| 123 | $this->addElement(  | 
            ||
| 124 | new XoopsFormText(  | 
            ||
| 125 | \AM_YOGURT_VIDEO_MAIN_VIDEO, 'main_video', 50, 255, $this->targetObject->getVar(  | 
            ||
| 126 | 'main_video'  | 
            ||
| 127 | )  | 
            ||
| 128 | ),  | 
            ||
| 129 | false  | 
            ||
| 130 | );  | 
            ||
| 131 | |||
| 132 | // Data_creation  | 
            ||
| 133 | |||
| 134 |         $this->addElement(new \XoopsFormTextDateSelect(\AM_YOGURT_VIDEO_DATE_CREATED, 'date_created', 0, \formatTimestamp($this->targetObject->getVar('date_created'), 's'))); | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 135 | |||
| 136 | $this->addElement(  | 
            ||
| 137 | new \XoopsFormTextDateSelect(  | 
            ||
| 138 |                 \AM_YOGURT_VIDEO_DATE_UPDATED, 'date_updated', 0, \formatTimestamp($this->targetObject->getVar('date_updated'), 's') | 
            ||
| 139 | )  | 
            ||
| 140 | );  | 
            ||
| 141 | |||
| 142 |         $this->addElement(new XoopsFormHidden('op', 'save')); | 
            ||
| 143 | |||
| 144 |         $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); | 
            ||
| 145 | }  | 
            ||
| 147 |