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 |
||
10 | class Generator |
||
11 | { |
||
12 | /** |
||
13 | * $filesystem. |
||
14 | * |
||
15 | * @var \Illuminate\Filesystem\Filesystem |
||
16 | */ |
||
17 | protected $filesystem; |
||
18 | |||
19 | /** |
||
20 | * $useSortFixer. |
||
21 | * |
||
22 | * @var \Recca0120\Generator\Fixers\UseSortFixer |
||
23 | */ |
||
24 | protected $useSortFixer; |
||
25 | |||
26 | /** |
||
27 | * $attributes. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $attributes = []; |
||
32 | |||
33 | /** |
||
34 | * __construct. |
||
35 | * |
||
36 | * @param \Illuminate\Filesystem\Filesystem $filesystem [description] |
||
37 | * @param \Recca0120\Generator\Fixers\UseSortFixers $useSortFixer [description] |
||
38 | */ |
||
39 | 9 | public function __construct(Filesystem $filesystem = null, UseSortFixer $useSortFixer = null) |
|
45 | |||
46 | /** |
||
47 | * parseAttribute. |
||
48 | * |
||
49 | * @param string $value |
||
50 | * @return array |
||
51 | */ |
||
52 | 9 | protected function parseAttribute($value) |
|
83 | |||
84 | /** |
||
85 | * setFullBaseClass. |
||
86 | * |
||
87 | * @param string $value |
||
88 | * @return static |
||
89 | */ |
||
90 | public function setFullBaseClass($value) |
||
103 | |||
104 | /** |
||
105 | * setFullRepositoryInterface. |
||
106 | * |
||
107 | * @param string $value |
||
108 | * @return static |
||
109 | */ |
||
110 | 1 | public function setFullRepositoryInterface($value) |
|
120 | |||
121 | /** |
||
122 | * setFullRepositoryClass. |
||
123 | * |
||
124 | * @param string $value |
||
125 | * @return static |
||
126 | */ |
||
127 | 3 | public function setFullRepositoryClass($value) |
|
138 | |||
139 | /** |
||
140 | * setFullModelClass. |
||
141 | * |
||
142 | * @param string $value |
||
143 | * @return static |
||
144 | */ |
||
145 | 1 | public function setFullModelClass($value) |
|
158 | |||
159 | /** |
||
160 | * setFullPresenterClass. |
||
161 | * |
||
162 | * @param string $value |
||
163 | * @return static |
||
164 | */ |
||
165 | 1 | public function setFullPresenterClass($value) |
|
175 | |||
176 | /** |
||
177 | * setFullRequestClass. |
||
178 | * |
||
179 | * @param string $value |
||
180 | * @return static |
||
181 | */ |
||
182 | 1 | public function setFullRequestClass($value) |
|
192 | |||
193 | /** |
||
194 | * setFullControllerClass. |
||
195 | * |
||
196 | * @param string $value |
||
197 | * @return static |
||
198 | */ |
||
199 | 2 | public function setFullControllerClass($value) |
|
214 | |||
215 | /** |
||
216 | * set. |
||
217 | * |
||
218 | * @param string $value |
||
219 | * @return static |
||
220 | */ |
||
221 | 9 | public function set($key, $value) |
|
227 | |||
228 | /** |
||
229 | * setDefault. |
||
230 | * |
||
231 | * @param string $value |
||
232 | * @return static |
||
233 | */ |
||
234 | protected function setDefault($key, $value) |
||
242 | |||
243 | /** |
||
244 | * get. |
||
245 | * |
||
246 | * @param string $value |
||
247 | * @return string |
||
248 | */ |
||
249 | public function get($key) |
||
253 | |||
254 | /** |
||
255 | * remove. |
||
256 | * |
||
257 | * @param string $key |
||
258 | * @return bool |
||
259 | */ |
||
260 | public function remove($key) |
||
264 | |||
265 | /** |
||
266 | * render. |
||
267 | * |
||
268 | * @param string $stub |
||
269 | * @param bool $orderedUses |
||
270 | * @return string |
||
271 | */ |
||
272 | public function render($stub, $orderedUses = true) |
||
281 | |||
282 | /** |
||
283 | * renderServiceProvider. |
||
284 | * |
||
285 | * @param string $content |
||
286 | * @return string |
||
287 | */ |
||
288 | public function renderServiceProvider($content) |
||
325 | |||
326 | /** |
||
327 | * replaceServieProviderCallback. |
||
328 | * |
||
329 | * @param array $match |
||
330 | * @return string |
||
331 | */ |
||
332 | protected function replaceServieProviderCallback($match) |
||
348 | |||
349 | /** |
||
350 | * getNamespace. |
||
351 | * |
||
352 | * @param string $name [description] |
||
353 | * @return string |
||
354 | */ |
||
355 | 9 | protected function getNamespace($name) |
|
359 | |||
360 | |||
361 | /** |
||
362 | * orderedUses. |
||
363 | * |
||
364 | * @param string $content |
||
365 | * @return string |
||
366 | */ |
||
367 | protected function orderedUses($content) |
||
373 | } |
||
374 |