Conditions | 12 |
Paths | 2048 |
Total Lines | 69 |
Code Lines | 31 |
Lines | 5 |
Ratio | 7.25 % |
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 |
||
116 | function moduleUpdate() |
||
117 | { |
||
118 | $oDB = DB::getInstance(); |
||
119 | $oModuleModel = getModel('module'); |
||
120 | $oModuleController = getController('module'); |
||
121 | // 2007. 10. 17 add a trigger to delete comments together with posting deleted |
||
122 | if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) |
||
123 | { |
||
124 | $oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'); |
||
125 | } |
||
126 | // 2007. 10. 17 add a trigger to delete all of comments together with module deleted |
||
127 | if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) |
||
128 | { |
||
129 | $oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'); |
||
130 | } |
||
131 | // 2007. 10. 23 add a column for recommendation votes or notification of the comments |
||
132 | if(!$oDB->isColumnExists("comments", "voted_count")) |
||
133 | { |
||
134 | $oDB->addColumn("comments", "voted_count", "number", "11"); |
||
135 | $oDB->addIndex("comments", "idx_voted_count", array("voted_count")); |
||
136 | } |
||
137 | |||
138 | if(!$oDB->isColumnExists("comments", "notify_message")) |
||
139 | { |
||
140 | $oDB->addColumn("comments", "notify_message", "char", "1"); |
||
141 | } |
||
142 | // 2008. 02. 22 add comment setting when a new module added |
||
143 | if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) |
||
144 | { |
||
145 | $oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'); |
||
146 | } |
||
147 | // 2008. 05. 14 add a column for blamed count |
||
148 | View Code Duplication | if(!$oDB->isColumnExists("comments", "blamed_count")) |
|
149 | { |
||
150 | $oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, TRUE); |
||
151 | $oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count')); |
||
152 | } |
||
153 | if(!$oDB->isColumnExists("comment_voted_log", "point")) |
||
154 | { |
||
155 | $oDB->addColumn('comment_voted_log', 'point', 'number', 11, 0, TRUE); |
||
156 | } |
||
157 | |||
158 | if(!$oDB->isIndexExists("comments", "idx_module_list_order")) |
||
159 | { |
||
160 | $oDB->addIndex( |
||
161 | "comments", "idx_module_list_order", array("module_srl", "list_order"), TRUE |
||
162 | ); |
||
163 | } |
||
164 | |||
165 | //2012. 02. 24 add comment published status column and index |
||
166 | if(!$oDB->isColumnExists("comments", "status")) |
||
167 | { |
||
168 | $oDB->addColumn("comments", "status", "number", 1, 1, TRUE); |
||
169 | } |
||
170 | if(!$oDB->isIndexExists("comments", "idx_status")) |
||
171 | { |
||
172 | $oDB->addIndex( |
||
173 | "comments", "idx_status", array("status", "comment_srl", "module_srl", "document_srl"), TRUE |
||
174 | ); |
||
175 | } |
||
176 | |||
177 | // 2012. 08. 29 Add a trigger to copy additional setting when the module is copied |
||
178 | if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after')) |
||
179 | { |
||
180 | $oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'comment', 'controller', 'triggerCopyModule', 'after'); |
||
181 | } |
||
182 | |||
183 | return new Object(0, 'success_updated'); |
||
184 | } |
||
185 | |||
201 |