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