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 |
||
14 | class PublishAdminLTE extends Command |
||
15 | { |
||
16 | /** |
||
17 | * The filesystem instance. |
||
18 | * |
||
19 | * @var \Illuminate\Filesystem\Filesystem |
||
20 | */ |
||
21 | protected $files; |
||
22 | |||
23 | /** |
||
24 | * The name and signature of the console command. |
||
25 | */ |
||
26 | protected $signature = 'adminlte-laravel:publish'; |
||
27 | |||
28 | /** |
||
29 | * The console command description. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $description = 'Publish Acacha AdminLTE Template files into laravel project'; |
||
34 | |||
35 | /** |
||
36 | * Create a new command instance. |
||
37 | * |
||
38 | * @param \Illuminate\Filesystem\Filesystem $files |
||
39 | * @return void |
||
|
|||
40 | */ |
||
41 | public function __construct(Filesystem $files) |
||
46 | |||
47 | /** |
||
48 | * Execute the console command. |
||
49 | * |
||
50 | */ |
||
51 | View Code Duplication | public function handle() |
|
62 | |||
63 | /** |
||
64 | * Install Home Controller. |
||
65 | */ |
||
66 | private function publishHomeController() |
||
70 | |||
71 | /** |
||
72 | * Install Auth controller. |
||
73 | */ |
||
74 | private function changeRegisterController() |
||
78 | |||
79 | /** |
||
80 | * Install public assets. |
||
81 | */ |
||
82 | private function publishPublicAssets() |
||
86 | |||
87 | /** |
||
88 | * Install views. |
||
89 | */ |
||
90 | private function publishViews() |
||
94 | |||
95 | /** |
||
96 | * Install resource assets. |
||
97 | */ |
||
98 | private function publishResourceAssets() |
||
102 | |||
103 | /** |
||
104 | * Install resource assets. |
||
105 | */ |
||
106 | private function publishTests() |
||
110 | |||
111 | /** |
||
112 | * Install language assets. |
||
113 | */ |
||
114 | private function publishLanguages() |
||
118 | |||
119 | /** |
||
120 | * Install gravatar config file. |
||
121 | */ |
||
122 | private function publishGravatar() |
||
126 | |||
127 | /** |
||
128 | * Install files from array. |
||
129 | * |
||
130 | * @param $files |
||
131 | */ |
||
132 | private function install($files) |
||
149 | |||
150 | /** |
||
151 | * @param $fileName |
||
152 | * @param string $prompt |
||
153 | * |
||
154 | * @return bool |
||
155 | */ |
||
156 | protected function confirmOverwrite($fileName, $prompt = '') |
||
163 | |||
164 | /** |
||
165 | * Create the directory to house the published files if needed. |
||
166 | * |
||
167 | * @param string $directory |
||
168 | * @return void |
||
169 | */ |
||
170 | protected function createParentDirectory($directory) |
||
176 | |||
177 | /** |
||
178 | * Publish the file to the given path. |
||
179 | * |
||
180 | * @param string $from |
||
181 | * @param string $to |
||
182 | * @return void |
||
183 | */ |
||
184 | protected function publishFile($from, $to) |
||
193 | |||
194 | /** |
||
195 | * Publish the directory to the given directory. |
||
196 | * |
||
197 | * @param string $from |
||
198 | * @param string $to |
||
199 | * @return void |
||
200 | */ |
||
201 | protected function publishDirectory($from, $to) |
||
214 | |||
215 | /** |
||
216 | * Write a status message to the console. |
||
217 | * |
||
218 | * @param string $from |
||
219 | * @param string $to |
||
220 | * @param string $type |
||
221 | * @return void |
||
222 | */ |
||
223 | protected function status($from, $to, $type) |
||
229 | } |
||
230 |
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.