Conditions | 4 |
Paths | 2 |
Total Lines | 92 |
Code Lines | 88 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
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 |
||
153 | public function getShortLogMessage() { |
||
154 | $section_name = $this->section_value; |
||
155 | $sub_section_name = $this->sub_section_value; |
||
156 | $messages = array( |
||
157 | "Games" => array( |
||
158 | "AKA" => array( |
||
159 | "Update" => "Updated $section_name", |
||
160 | "Insert" => "Added $sub_section_name to $section_name", |
||
161 | "Delete" => "Removed $sub_section_name from $section_name"), |
||
162 | "Box back" => array( |
||
163 | "Update" => "Updated the boxscan of $section_name", |
||
164 | "Insert" => "Added boxscan to $section_name", |
||
165 | "Delete" =>"Removed a boxscan from $section_name"), |
||
166 | "Box front" => array( |
||
167 | "Update" => "Updated the boxscan of $section_name", |
||
168 | "Insert" => "Added boxscan to $section_name", |
||
169 | "Delete" => "Removed a boxscan from $section_name"), |
||
170 | "Comment" => array( |
||
171 | "Update" => "Updated a comment on $section_name", |
||
172 | "Insert" => "Added a comment on $section_name", |
||
173 | "Delete" => "Removed a comment on $section_name"), |
||
174 | "Creator" => array( |
||
175 | "Update" => "Updated $section_name", |
||
176 | "Insert" => "Added $sub_section_name to $section_name", |
||
177 | "Delete" => "Removed $sub_section_name from $section_name"), |
||
178 | "Developer" => array( |
||
179 | "Update" => "Updated the developer of $section_name", |
||
180 | "Insert" => "Added $sub_section_name to $section_name", |
||
181 | "Delete" => "Removed $sub_section_name from $section_name"), |
||
182 | "Fact" => array( |
||
183 | "Update" => "Updated $section_name", |
||
184 | "Insert" => "Added fact to $section_name", |
||
185 | "Delete" =>"Removed a fact from $section_name", |
||
186 | "Delete shot" => "Removed a fact shot from $section_name"), |
||
187 | "File" => array( |
||
188 | "Update" => "Updated $section_name", |
||
189 | "Insert" => "Added a file to $section_name", |
||
190 | "Delete" =>"Removed a file from $section_name"), |
||
191 | "Mag score" => array( |
||
192 | "Update" => "Updated $section_name", |
||
193 | "Insert" => "Added a mag score to $section_name", |
||
194 | "Delete" =>"Removed a mag score from $section_name"), |
||
195 | "Music" => array( |
||
196 | "Update" => "Updated $section_name", |
||
197 | "Insert" => "Added music to $section_name", |
||
198 | "Delete" =>"Removed music from $section_name"), |
||
199 | "Game" => array( |
||
200 | "Update" => "Updated $section_name", |
||
201 | "Insert" => "Added a new game: $section_name", |
||
202 | "Delete" => "Removed $section_name"), |
||
203 | "Publisher" => array( |
||
204 | "Update" => "Updated the publisher of $section_name", |
||
205 | "Insert" => "Added $sub_section_name to $section_name", |
||
206 | "Delete" => "Removed $sub_section_name from $section_name"), |
||
207 | "Review" => array( |
||
208 | "Update" => "Updated a review of $sub_section_name", |
||
209 | "Insert" => "Added a review to $section_name", |
||
210 | "Delete" => "Removed a review from $section_name"), |
||
211 | "Release" => array( |
||
212 | "Update" => "Updated a release of $section_name", |
||
213 | "Insert" => "Added a release to $section_name", |
||
214 | "Delete" => "Removed a release from $section_name"), |
||
215 | "Screenshot" => array( |
||
216 | "Update" => "Updated the screenshots of $section_name", |
||
217 | "Insert" => "Added a screenshot to $section_name", |
||
218 | "Delete" => "Removed a screenshot from $section_name"), |
||
219 | "Similar" => array( |
||
220 | "Update" => "Updated $section_name", |
||
221 | "Insert" => "Added $sub_section_name as similar to $section_name", |
||
222 | "Delete" => "Updated $section_name"), |
||
223 | "Sound hardware" => array( |
||
224 | "Update" => "Updated $section_name", |
||
225 | "Insert" => "Added sound hardware to $section_name", |
||
226 | "Delete" => "Updated $section_name"), |
||
227 | "Submission" => array( |
||
228 | "Update" => "Updated info submission for $section_name", |
||
229 | "Insert" => "Submitted info for $section_name", |
||
230 | "Delete" => "Removed an info submission for $section_name"), |
||
231 | "Vs" => array( |
||
232 | "Update" => "Updated versus info for $section_name", |
||
233 | "Insert" => "Submitted versus info for $section_name", |
||
234 | "Delete" => "Removed a versus info for $section_name"), |
||
235 | ) |
||
236 | ); |
||
237 | |||
238 | if (array_key_exists($this->section, $messages) |
||
239 | && array_key_exists($this->sub_section, $messages[$this->section]) |
||
240 | && array_key_exists($this->action, $messages[$this->section][$this->sub_section])) { |
||
241 | return $messages[$this->section][$this->sub_section][$this->action]; |
||
242 | } else { |
||
243 | return "ERROR: Message missing in ChangeLog.php for section {$this->section}, |
||
244 | sub-section {$this->sub_section}, action {$this->action}"; |
||
245 | } |
||
248 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.