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; |
||
17 | class SeederMakeCommand extends \Illuminate\Console\Command |
||
18 | { |
||
19 | use DispatchesJobs; |
||
20 | |||
21 | /** |
||
22 | * The console command name. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $name = 'make:seeder'; |
||
27 | |||
28 | /** |
||
29 | * The console command description. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $description = 'Create a new seeder class for addon'; |
||
34 | |||
35 | /** |
||
36 | * All streams string value |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $allChoice = 'All streams'; |
||
41 | |||
42 | /** |
||
43 | * The Composer instance. |
||
44 | * |
||
45 | * @var \Illuminate\Support\Composer |
||
46 | */ |
||
47 | protected $composer; |
||
48 | |||
49 | /** |
||
50 | * Create a new command instance. |
||
51 | * |
||
52 | * @param \Illuminate\Filesystem\Filesystem $files |
||
53 | * @param \Illuminate\Support\Composer $composer |
||
54 | * @return void |
||
|
|||
55 | */ |
||
56 | public function __construct(Filesystem $files, Composer $composer) |
||
62 | |||
63 | /** |
||
64 | * Execute the console command. |
||
65 | * |
||
66 | * @return void |
||
67 | */ |
||
68 | public function fire() |
||
127 | |||
128 | /** |
||
129 | * Gets the addon's stream namespace. |
||
130 | * |
||
131 | * @throws \Exception |
||
132 | * @return string The stream namespace. |
||
133 | */ |
||
134 | public function getAddonNamespace() |
||
145 | |||
146 | /** |
||
147 | * Gets the root streams of addon. |
||
148 | * |
||
149 | * @param string $slug The addon slug |
||
150 | * @return StreamCollection |
||
151 | */ |
||
152 | public function getStreams($slug) |
||
161 | |||
162 | /** |
||
163 | * Get `all` value. |
||
164 | * |
||
165 | * @return string All value. |
||
166 | */ |
||
167 | public function getAllChoice() |
||
171 | |||
172 | /** |
||
173 | * Makes a question about streams to make seeders for. |
||
174 | * |
||
175 | * @param StreamCollection $streams The streams |
||
176 | * @return array Answers |
||
177 | */ |
||
178 | public function makeQuestion(StreamCollection $streams) |
||
192 | |||
193 | /** |
||
194 | * Get the options. |
||
195 | * |
||
196 | * @return array |
||
197 | */ |
||
198 | View Code Duplication | protected function getOptions() |
|
208 | |||
209 | /** |
||
210 | * Get the console command arguments. |
||
211 | * |
||
212 | * @return array |
||
213 | */ |
||
214 | protected function getArguments() |
||
220 | } |
||
221 |
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.