| Conditions | 1 |
| Paths | 1 |
| Total Lines | 70 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
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 |
||
| 12 | public function run() |
||
| 13 | { |
||
| 14 | \DB::table('models')->delete(); |
||
| 15 | |||
| 16 | \DB::table('models')->insert([ |
||
| 17 | 0 => [ |
||
| 18 | 'id' => 1, |
||
| 19 | 'make_id' => 2, |
||
| 20 | 'name' => '1G-1', |
||
| 21 | 'photo' => 'images/e422457682369fd5a176bc2b711750ea55611abd.jpg', |
||
| 22 | 'deleted_at' => null, |
||
| 23 | ], |
||
| 24 | 1 => [ |
||
| 25 | 'id' => 2, |
||
| 26 | 'make_id' => 2, |
||
| 27 | 'name' => '100 Series', |
||
| 28 | 'photo' => 'images/6d162048307629e84559fef71935feeb1555b789.jpg', |
||
| 29 | 'deleted_at' => null, |
||
| 30 | ], |
||
| 31 | 2 => [ |
||
| 32 | 'id' => 3, |
||
| 33 | 'make_id' => 2, |
||
| 34 | 'name' => '100 Series Delta Player', |
||
| 35 | 'photo' => 'images/ce92299bb79ab4b54dfdf2097790e4fef5ebc3c8.jpg', |
||
| 36 | 'deleted_at' => null, |
||
| 37 | ], |
||
| 38 | 3 => [ |
||
| 39 | 'id' => 4, |
||
| 40 | 'make_id' => 2, |
||
| 41 | 'name' => '200 Series', |
||
| 42 | 'photo' => 'images/a81c9f2f24018cf6e31e6b4085df8557b5a6e32e.jpg', |
||
| 43 | 'deleted_at' => null, |
||
| 44 | ], |
||
| 45 | 4 => [ |
||
| 46 | 'id' => 5, |
||
| 47 | 'make_id' => 2, |
||
| 48 | 'name' => '500 Series', |
||
| 49 | 'photo' => 'images/81962e3d81810a5cd668ce409c1aefa60c337c9a.jpg', |
||
| 50 | 'deleted_at' => null, |
||
| 51 | ], |
||
| 52 | 6 => [ |
||
| 53 | 'id' => 7, |
||
| 54 | 'make_id' => 1, |
||
| 55 | 'name' => '714/615 Series', |
||
| 56 | 'photo' => 'images/5ef886bc0575a3cce636c3238d47dc7646425810.jpg', |
||
| 57 | 'deleted_at' => null, |
||
| 58 | ], |
||
| 59 | 7 => [ |
||
| 60 | 'id' => 8, |
||
| 61 | 'make_id' => 1, |
||
| 62 | 'name' => 'ClassAxe', |
||
| 63 | 'photo' => 'images/f448d7a4d16d7ddd2179481637d4e18e60fdb9a4.jpg', |
||
| 64 | 'deleted_at' => null, |
||
| 65 | ], |
||
| 66 | 8 => [ |
||
| 67 | 'id' => 9, |
||
| 68 | 'make_id' => 1, |
||
| 69 | 'name' => 'HollowBody', |
||
| 70 | 'photo' => 'images/cfcb9f46cf8417c340aca1f4694afdeb6c9de216.jpg', |
||
| 71 | 'deleted_at' => null, |
||
| 72 | ], |
||
| 73 | 9 => [ |
||
| 74 | 'id' => 10, |
||
| 75 | 'make_id' => 1, |
||
| 76 | 'name' => 'Mac Series', |
||
| 77 | 'photo' => 'images/bafd2f462c4c0788bcc363879bd9586557e948cb.jpg', |
||
| 78 | 'deleted_at' => null, |
||
| 79 | ], |
||
| 80 | ]); |
||
| 81 | } |
||
| 82 | } |
||
| 83 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.