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 Limoncello\Core\Application; |
||
27 | abstract class BaseCoreData implements CoreDataInterface |
||
28 | { |
||
29 | use ClassIsTrait; |
||
30 | |||
31 | /** |
||
32 | * @param array $data |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | 8 | public static function getRouterParametersFromData(array $data): array |
|
44 | |||
45 | /** |
||
46 | * @param array $data |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | 8 | View Code Duplication | public static function getGeneratorFromParametersData(array $data): string |
59 | |||
60 | /** |
||
61 | * @param array $data |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 8 | View Code Duplication | public static function getDispatcherFromParametersData(array $data): string |
74 | |||
75 | /** |
||
76 | * @param array $data |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | 8 | public static function getRoutesDataFromData(array $data): array |
|
87 | |||
88 | /** |
||
89 | * @param array $data |
||
90 | * |
||
91 | * @return callable[] |
||
92 | */ |
||
93 | 8 | public static function getGlobalConfiguratorsFromData(array $data): array |
|
100 | |||
101 | /** |
||
102 | * @param array $data |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | 8 | public static function getGlobalMiddlewareFromData(array $data): array |
|
113 | } |
||
114 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.