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; |
||
13 | class SeederMakeCommand extends \Illuminate\Console\Command |
||
14 | { |
||
15 | use DispatchesJobs; |
||
16 | |||
17 | /** |
||
18 | * The console command name. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $name = 'make:seeder'; |
||
23 | |||
24 | /** |
||
25 | * The console command description. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $description = 'Create a new seeder class for addon'; |
||
30 | |||
31 | /** |
||
32 | * The Composer instance. |
||
33 | * |
||
34 | * @var \Illuminate\Support\Composer |
||
35 | */ |
||
36 | protected $composer; |
||
37 | |||
38 | /** |
||
39 | * Create a new command instance. |
||
40 | * |
||
41 | * @param \Illuminate\Filesystem\Filesystem $files |
||
42 | * @param \Illuminate\Support\Composer $composer |
||
43 | * @return void |
||
|
|||
44 | */ |
||
45 | public function __construct(Filesystem $files, Composer $composer) |
||
51 | |||
52 | /** |
||
53 | * Execute the console command. |
||
54 | * |
||
55 | * @return void |
||
56 | */ |
||
57 | public function fire() |
||
98 | |||
99 | /** |
||
100 | * Get the options. |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | View Code Duplication | protected function getOptions() |
|
114 | |||
115 | /** |
||
116 | * Get the console command arguments. |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | protected function getArguments() |
||
126 | |||
127 | /** |
||
128 | * Gets the stream namespace. |
||
129 | * |
||
130 | * @throws \Exception |
||
131 | * @return string The stream namespace. |
||
132 | */ |
||
133 | public function getAddonNamespace() |
||
144 | |||
145 | /** |
||
146 | * Gets the streams. |
||
147 | * |
||
148 | * @param string $slug The addon slug |
||
149 | * @return StreamCollection |
||
150 | */ |
||
151 | public function getStreams($slug) |
||
160 | } |
||
161 |
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.