Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php namespace Anomaly\Streams\Platform\Database\Seeder\Console; |
||
14 | class SeederMakeCommand extends \Illuminate\Console\Command |
||
15 | { |
||
16 | use DispatchesJobs; |
||
17 | |||
18 | /** |
||
19 | * The console command name. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $name = 'make:seeder'; |
||
24 | |||
25 | /** |
||
26 | * The console command description. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $description = 'Create a new seeder class for addon'; |
||
31 | |||
32 | /** |
||
33 | * All streams string value |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $allChoice = 'All streams'; |
||
38 | |||
39 | /** |
||
40 | * The Composer instance. |
||
41 | * |
||
42 | * @var \Illuminate\Support\Composer |
||
43 | */ |
||
44 | protected $composer; |
||
45 | |||
46 | /** |
||
47 | * Create a new command instance. |
||
48 | * |
||
49 | * @param \Illuminate\Filesystem\Filesystem $files |
||
50 | * @param \Illuminate\Support\Composer $composer |
||
51 | * @return void |
||
|
|||
52 | */ |
||
53 | public function __construct(Filesystem $files, Composer $composer) |
||
59 | |||
60 | /** |
||
61 | * Execute the console command. |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public function fire() |
||
124 | |||
125 | /** |
||
126 | * Gets the addon's stream namespace. |
||
127 | * |
||
128 | * @throws \Exception |
||
129 | * @return string The stream namespace. |
||
130 | */ |
||
131 | public function getAddonNamespace() |
||
142 | |||
143 | /** |
||
144 | * Gets the root streams of addon. |
||
145 | * |
||
146 | * @param string $slug The addon slug |
||
147 | * @return StreamCollection |
||
148 | */ |
||
149 | public function getStreams($slug) |
||
158 | |||
159 | /** |
||
160 | * Get `all` value. |
||
161 | * |
||
162 | * @return string All value. |
||
163 | */ |
||
164 | public function getAllChoice() |
||
168 | |||
169 | /** |
||
170 | * Makes a question about streams to make seeders for. |
||
171 | * |
||
172 | * @param StreamCollection $streams The streams |
||
173 | * @return array Answers |
||
174 | */ |
||
175 | public function makeQuestion(StreamCollection $streams) |
||
189 | |||
190 | /** |
||
191 | * Get the options. |
||
192 | * |
||
193 | * @return array |
||
194 | */ |
||
195 | View Code Duplication | protected function getOptions() |
|
205 | |||
206 | /** |
||
207 | * Get the console command arguments. |
||
208 | * |
||
209 | * @return array |
||
210 | */ |
||
211 | protected function getArguments() |
||
217 | } |
||
218 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.