| Conditions | 1 |
| Paths | 1 |
| Total Lines | 93 |
| Code Lines | 54 |
| 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 |
||
| 19 | public function run() |
||
| 20 | { |
||
| 21 | $data = |
||
| 22 | [ |
||
| 23 | [ |
||
| 24 | 'id' => 1, |
||
| 25 | 'sort' => 1, |
||
| 26 | 'icon' => 'happy', |
||
| 27 | ], |
||
| 28 | [ |
||
| 29 | 'id' => 2, |
||
| 30 | 'sort' => 2, |
||
| 31 | 'icon' => 'grin', |
||
| 32 | ], |
||
| 33 | [ |
||
| 34 | 'id' => 3, |
||
| 35 | 'sort' => 3, |
||
| 36 | 'icon' => 'wink', |
||
| 37 | ], |
||
| 38 | [ |
||
| 39 | 'id' => 4, |
||
| 40 | 'sort' => 4, |
||
| 41 | 'icon' => 'saint', |
||
| 42 | ], |
||
| 43 | [ |
||
| 44 | 'id' => 5, |
||
| 45 | 'sort' => 5, |
||
| 46 | 'icon' => 'squint', |
||
| 47 | ], |
||
| 48 | [ |
||
| 49 | 'id' => 6, |
||
| 50 | 'sort' => 6, |
||
| 51 | 'icon' => 'sunglasses', |
||
| 52 | ], |
||
| 53 | [ |
||
| 54 | 'id' => 7, |
||
| 55 | 'sort' => 7, |
||
| 56 | 'icon' => 'heart-empty-1', |
||
| 57 | ], |
||
| 58 | [ |
||
| 59 | 'id' => 8, |
||
| 60 | 'sort' => 8, |
||
| 61 | 'icon' => 'thumbsup', |
||
| 62 | ], |
||
| 63 | [ |
||
| 64 | 'id' => 9, |
||
| 65 | 'sort' => 9, |
||
| 66 | 'icon' => 'coffee', |
||
| 67 | ], |
||
| 68 | [ |
||
| 69 | 'id' => 10, |
||
| 70 | 'sort' => 10, |
||
| 71 | 'icon' => 'tongue', |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | 'id' => 11, |
||
| 75 | 'sort' => 11, |
||
| 76 | 'icon' => 'devil', |
||
| 77 | ], |
||
| 78 | [ |
||
| 79 | 'id' => 12, |
||
| 80 | 'sort' => 12, |
||
| 81 | 'icon' => 'sleep', |
||
| 82 | ], |
||
| 83 | [ |
||
| 84 | 'id' => 13, |
||
| 85 | 'sort' => 13, |
||
| 86 | 'icon' => 'surprised', |
||
| 87 | ], |
||
| 88 | [ |
||
| 89 | 'id' => 14, |
||
| 90 | 'sort' => 14, |
||
| 91 | 'icon' => 'displeased', |
||
| 92 | ], |
||
| 93 | [ |
||
| 94 | 'id' => 15, |
||
| 95 | 'sort' => 15, |
||
| 96 | 'icon' => 'unhappy', |
||
| 97 | ], |
||
| 98 | [ |
||
| 99 | 'id' => 16, |
||
| 100 | 'sort' => 16, |
||
| 101 | 'icon' => 'cry', |
||
| 102 | ], |
||
| 103 | [ |
||
| 104 | 'id' => 17, |
||
| 105 | 'sort' => 17, |
||
| 106 | 'icon' => 'angry', |
||
| 107 | ] |
||
| 108 | ]; |
||
| 109 | |||
| 110 | $table = $this->table('smilies'); |
||
| 111 | $table->insert($data)->save(); |
||
| 112 | } |
||
| 114 |