| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 13 | public function run() |
||
| 14 | { |
||
| 15 | \DB::table('racks')->delete(); |
||
| 16 | |||
| 17 | \DB::table('racks')->insert(array ( |
||
| 18 | 0 => |
||
| 19 | array ( |
||
| 20 | 'id' => 1, |
||
| 21 | 'warehouse_id' => 1, |
||
| 22 | 'name' => 'Rack #1', |
||
| 23 | 'make_id' => 2, |
||
| 24 | 'capacity' => 10, |
||
| 25 | 'deleted_at' => NULL, |
||
| 26 | ), |
||
| 27 | 1 => |
||
| 28 | array ( |
||
| 29 | 'id' => 2, |
||
| 30 | 'warehouse_id' => 1, |
||
| 31 | 'name' => 'Rack #2', |
||
| 32 | 'make_id' => 2, |
||
| 33 | 'capacity' => 20, |
||
| 34 | 'deleted_at' => NULL, |
||
| 35 | ), |
||
| 36 | 2 => |
||
| 37 | array ( |
||
| 38 | 'id' => 3, |
||
| 39 | 'warehouse_id' => 1, |
||
| 40 | 'name' => 'Rack #3', |
||
| 41 | 'make_id' => 2, |
||
| 42 | 'capacity' => 5, |
||
| 43 | 'deleted_at' => NULL, |
||
| 44 | ), |
||
| 45 | 3 => |
||
| 46 | array ( |
||
| 47 | 'id' => 4, |
||
| 48 | 'warehouse_id' => 1, |
||
| 49 | 'name' => 'Rack #4', |
||
| 50 | 'make_id' => 1, |
||
| 51 | 'capacity' => 5, |
||
| 52 | 'deleted_at' => NULL, |
||
| 53 | ), |
||
| 54 | 4 => |
||
| 55 | array ( |
||
| 56 | 'id' => 5, |
||
| 57 | 'warehouse_id' => 1, |
||
| 58 | 'name' => 'Rack #5', |
||
| 59 | 'make_id' => 1, |
||
| 60 | 'capacity' => 10, |
||
| 61 | 'deleted_at' => NULL, |
||
| 62 | ), |
||
| 63 | 5 => |
||
| 64 | array ( |
||
| 65 | 'id' => 6, |
||
| 66 | 'warehouse_id' => 1, |
||
| 67 | 'name' => 'Rack #6', |
||
| 68 | 'make_id' => 1, |
||
| 69 | 'capacity' => 20, |
||
| 70 | 'deleted_at' => NULL, |
||
| 71 | ), |
||
| 72 | )); |
||
| 73 | } |
||
| 74 | } |
||
| 75 |
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.