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() |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Gets the addon's stream namespace. |
||
| 137 | * |
||
| 138 | * @throws \Exception |
||
| 139 | * @return string The stream namespace. |
||
| 140 | */ |
||
| 141 | public function getAddonNamespace() |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Gets the root streams of addon. |
||
| 155 | * |
||
| 156 | * @param string $slug The addon slug |
||
| 157 | * @return StreamCollection |
||
| 158 | */ |
||
| 159 | public function getStreams($slug) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Get `all` value. |
||
| 171 | * |
||
| 172 | * @return string All value. |
||
| 173 | */ |
||
| 174 | public function getAllChoice() |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Makes a question about streams to make seeders for. |
||
| 181 | * |
||
| 182 | * @param StreamCollection $streams The streams |
||
| 183 | * @return array Answers |
||
| 184 | */ |
||
| 185 | public function makeQuestion(StreamCollection $streams) |
||
| 199 | |||
| 200 | /** |
||
| 201 | * Get the options. |
||
| 202 | * |
||
| 203 | * @return array |
||
| 204 | */ |
||
| 205 | View Code Duplication | protected function getOptions() |
|
| 215 | |||
| 216 | /** |
||
| 217 | * Get the console command arguments. |
||
| 218 | * |
||
| 219 | * @return array |
||
| 220 | */ |
||
| 221 | protected function getArguments() |
||
| 227 | } |
||
| 228 |
Adding a
@returnannotation 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.