Conditions | 1 |
Paths | 1 |
Total Lines | 85 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
16 | public function run() |
||
17 | { |
||
18 | // $faker = new Faker; |
||
19 | $faker = Faker\Factory::create('en_US'); |
||
20 | |||
21 | // Create random file links for different users |
||
22 | factory(FileLinks::class, 5)->create([ |
||
23 | 'user_id' => 1, |
||
24 | 'note' =>$faker->text |
||
25 | ]); |
||
26 | |||
27 | factory(FileLinks::class, 2)->create([ |
||
28 | 'user_id' => 2 |
||
29 | ]); |
||
30 | |||
31 | factory(FileLinks::class, 8)->create([ |
||
32 | 'user_id' => 3 |
||
33 | ]); |
||
34 | |||
35 | factory(FileLinks::class, 2)->create([ |
||
36 | 'user_id' => 1, |
||
37 | 'cust_id' => 2387 |
||
38 | ]); |
||
39 | |||
40 | // Add files to the first file link |
||
41 | $fileID = Files::create([ |
||
42 | 'file_name' => 'file1.png', |
||
43 | 'file_link' => 'random/path' |
||
44 | ]); |
||
45 | FileLinkFiles::create([ |
||
46 | 'link_id' => 1, |
||
47 | 'file_id' => $fileID->file_id, |
||
48 | 'user_id' => 1, |
||
49 | 'added_by' => null, |
||
50 | 'upload' => 0 |
||
51 | ]); |
||
52 | |||
53 | $fileID = Files::create([ |
||
54 | 'file_name' => 'file2.png', |
||
55 | 'file_link' => 'random/path' |
||
56 | ]); |
||
57 | FileLinkFiles::create([ |
||
58 | 'link_id' => 1, |
||
59 | 'file_id' => $fileID->file_id, |
||
60 | 'user_id' => 1, |
||
61 | 'added_by' => null, |
||
62 | 'upload' => 0 |
||
63 | ]); |
||
64 | |||
65 | $fileID = Files::create([ |
||
66 | 'file_name' => 'file3.png', |
||
67 | 'file_link' => 'random/path' |
||
68 | ]); |
||
69 | FileLinkFiles::create([ |
||
70 | 'link_id' => 1, |
||
71 | 'file_id' => $fileID->file_id, |
||
72 | 'user_id' => 1, |
||
73 | 'added_by' => null, |
||
74 | 'upload' => 0 |
||
75 | ]); |
||
76 | |||
77 | $fileID = Files::create([ |
||
78 | 'file_name' => 'file4.png', |
||
79 | 'file_link' => 'random/path' |
||
80 | ]); |
||
81 | FileLinkFiles::create([ |
||
82 | 'link_id' => 1, |
||
83 | 'file_id' => $fileID->file_id, |
||
84 | 'user_id' => null, |
||
85 | 'added_by' => $faker->name(), |
||
86 | 'upload' => 1 |
||
87 | ]); |
||
88 | |||
89 | $fileID = Files::create([ |
||
90 | 'file_name' => 'file5.png', |
||
91 | 'file_link' => 'random/path' |
||
92 | ]); |
||
93 | FileLinkFiles::create([ |
||
94 | 'link_id' => 1, |
||
95 | 'file_id' => $fileID->file_id, |
||
96 | 'user_id' => null, |
||
97 | 'added_by' => $faker->name(), |
||
98 | 'upload' => 1 |
||
99 | ]); |
||
100 | } |
||
101 | } |
||
102 |