| Conditions | 1 |
| Paths | 1 |
| Total Lines | 73 |
| Code Lines | 63 |
| 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('sales')->delete(); |
||
| 16 | |||
| 17 | \DB::table('sales')->insert(array ( |
||
| 18 | 0 => |
||
| 19 | array ( |
||
| 20 | 'id' => 1, |
||
| 21 | 'guitar_id' => 10, |
||
| 22 | 'name' => 'XYZ Shop', |
||
| 23 | 'address' => 'Naxal', |
||
| 24 | 'shop_id' => 1, |
||
| 25 | 'created_at' => '2016-04-18 13:13:36', |
||
| 26 | 'updated_at' => '2016-04-18 13:13:36', |
||
| 27 | 'deleted_at' => NULL, |
||
| 28 | ), |
||
| 29 | 1 => |
||
| 30 | array ( |
||
| 31 | 'id' => 2, |
||
| 32 | 'guitar_id' => 4, |
||
| 33 | 'name' => 'Ram Prasad', |
||
| 34 | 'address' => 'New Road', |
||
| 35 | 'shop_id' => NULL, |
||
| 36 | 'created_at' => '2016-04-18 13:14:36', |
||
| 37 | 'updated_at' => '2016-04-18 13:14:36', |
||
| 38 | 'deleted_at' => NULL, |
||
| 39 | ), |
||
| 40 | 2 => |
||
| 41 | array ( |
||
| 42 | 'id' => 3, |
||
| 43 | 'guitar_id' => 37, |
||
| 44 | 'name' => 'Nikhil Pandey', |
||
| 45 | 'address' => 'Kalopul', |
||
| 46 | 'shop_id' => NULL, |
||
| 47 | 'created_at' => '2016-04-18 13:23:10', |
||
| 48 | 'updated_at' => '2016-04-18 13:23:10', |
||
| 49 | 'deleted_at' => NULL, |
||
| 50 | ), |
||
| 51 | 3 => |
||
| 52 | array ( |
||
| 53 | 'id' => 4, |
||
| 54 | 'guitar_id' => 36, |
||
| 55 | 'name' => 'John Doe', |
||
| 56 | 'address' => 'Jawlakhel', |
||
| 57 | 'shop_id' => NULL, |
||
| 58 | 'created_at' => '2016-04-18 13:23:35', |
||
| 59 | 'updated_at' => '2016-04-18 13:23:35', |
||
| 60 | 'deleted_at' => NULL, |
||
| 61 | ), |
||
| 62 | 4 => |
||
| 63 | array ( |
||
| 64 | 'id' => 5, |
||
| 65 | 'guitar_id' => 35, |
||
| 66 | 'name' => 'Jane Doe', |
||
| 67 | 'address' => 'Lalitpur', |
||
| 68 | 'shop_id' => NULL, |
||
| 69 | 'created_at' => '2016-04-18 13:23:57', |
||
| 70 | 'updated_at' => '2016-04-18 13:23:57', |
||
| 71 | 'deleted_at' => NULL, |
||
| 72 | ), |
||
| 73 | 5 => |
||
| 74 | array ( |
||
| 75 | 'id' => 6, |
||
| 76 | 'guitar_id' => 33, |
||
| 77 | 'name' => 'Jane Doe', |
||
| 78 | 'address' => 'Lalitpur', |
||
| 79 | 'shop_id' => NULL, |
||
| 80 | 'created_at' => '2016-04-18 13:24:11', |
||
| 81 | 'updated_at' => '2016-04-18 13:24:11', |
||
| 82 | 'deleted_at' => NULL, |
||
| 83 | ), |
||
| 84 | )); |
||
| 85 | } |
||
| 86 | } |
||
| 87 |
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.