Conditions | 1 |
Paths | 1 |
Total Lines | 83 |
Code Lines | 45 |
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 |
||
191 | public function diffProvider() |
||
192 | { |
||
193 | return [ |
||
194 | // [ 1st table option string, 2nd table option string, expected result ] |
||
195 | |||
196 | // AVG_ROW_LENGTH |
||
197 | ["", "avg_row_length=100", "AVG_ROW_LENGTH=100"], |
||
198 | ["avg_row_length=200", "", "AVG_ROW_LENGTH=0"], |
||
199 | ["avg_row_length=100", "avg_row_length=200", "AVG_ROW_LENGTH=200"], |
||
200 | |||
201 | // CHARSET |
||
202 | ["", "charset latin1", "DEFAULT CHARSET=latin1"], |
||
203 | ["charset latin1", "", ""], |
||
204 | ["charset default", "charset utf8", "DEFAULT CHARSET=utf8"], |
||
205 | |||
206 | // COLLATE |
||
207 | ["", "collate=utf8_unicode_ci", "DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"], |
||
208 | ["collate=utf8_unicode_ci", "", ""], |
||
209 | ["collate=utf8_unicode_ci", "collate=latin1_german1_ci", "DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci"], |
||
210 | |||
211 | // CHECKSUM |
||
212 | ["", "checksum=1", "CHECKSUM=1"], |
||
213 | ["checksum=1", "", "CHECKSUM=0"], |
||
214 | ["checksum=1", "checksum=0", "CHECKSUM=0"], |
||
215 | |||
216 | // COMMENT |
||
217 | ["comment 'hello'", "", "COMMENT=''"], |
||
218 | ["", "comment 'hello'", "COMMENT='hello'"], |
||
219 | ["comment 'hello'", "comment 'goodbye'", "COMMENT='goodbye'"], |
||
220 | |||
221 | // CONNECTION |
||
222 | ["connection 'foo'", "", "CONNECTION=''" ], |
||
223 | ["", "connection 'foo'", "CONNECTION='foo'"], |
||
224 | ["connection 'foo'", "connection 'bar'", "CONNECTION='bar'"], |
||
225 | |||
226 | // DELAY_KEY_WRITE |
||
227 | ["", "delay_key_write=1", "DELAY_KEY_WRITE=1"], |
||
228 | ["delay_key_write=1", "", "DELAY_KEY_WRITE=0"], |
||
229 | ["delay_key_write=1", "delay_key_write=0", "DELAY_KEY_WRITE=0"], |
||
230 | |||
231 | // ENGINE |
||
232 | ["", "engine=memory", "ENGINE=MEMORY"], |
||
233 | ["engine=InnoDB", "", ""], |
||
234 | ["engine=InnoDB", "engine=MyISAM", "ENGINE=MyISAM"], |
||
235 | |||
236 | // KEY_BLOCK_SIZE |
||
237 | ["", "key_block_size=4", "KEY_BLOCK_SIZE=4"], |
||
238 | ["key_block_size=8", "", "KEY_BLOCK_SIZE=0"], |
||
239 | ["key_block_size=4", "key_block_size=16", "KEY_BLOCK_SIZE=16"], |
||
240 | |||
241 | // MAX_ROWS |
||
242 | ["", "max_rows=100", "MAX_ROWS=100"], |
||
243 | ["max_rows=200", "", "MAX_ROWS=0"], |
||
244 | ["max_rows=100", "max_rows=200", "MAX_ROWS=200"], |
||
245 | |||
246 | // MIN_ROWS |
||
247 | ["", "min_rows=100", "MIN_ROWS=100"], |
||
248 | ["min_rows=200", "", "MIN_ROWS=0"], |
||
249 | ["min_rows=100", "min_rows=200", "MIN_ROWS=200"], |
||
250 | |||
251 | // PACK_KEYS |
||
252 | ["", "pack_keys=1", "PACK_KEYS=1"], |
||
253 | ["pack_keys=0", "", "PACK_KEYS=DEFAULT"], |
||
254 | ["pack_keys=1", "pack_keys=default", "PACK_KEYS=DEFAULT"], |
||
255 | |||
256 | /* |
||
257 | * Everything below here is currently unsupported by the |
||
258 | * diff() function and so has an expected value of an empty string. |
||
259 | * These should be moved up as and when support is added. |
||
260 | */ |
||
261 | |||
262 | // AUTO_INCREMENT |
||
263 | ["", "auto_increment 1", ""], |
||
264 | ["", "auto_increment 5", ""], |
||
265 | ["auto_increment 1", "", ""], |
||
266 | ["auto_increment 3", "auto_increment 5", ""], |
||
267 | |||
268 | // ROW_FORMAT |
||
269 | ["", "row_format=compressed", ""], |
||
270 | ["row_format=fixed", "", ""], |
||
271 | ["row_format=compact", "row_format=redundant", ""] |
||
272 | ]; |
||
273 | } |
||
274 | |||
291 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.