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 |
||
18 | View Code Duplication | Class Glossary extends Package |
|
|
|||
19 | { |
||
20 | /** |
||
21 | * Download Crowdin project glossaries as TBX file. |
||
22 | * |
||
23 | * @param boolean $includeAssigned Defines whether the assigned glossaries should be included in downloaded TBX file. |
||
24 | * Acceptable values are: 0, 1. |
||
25 | * Default is 1. |
||
26 | * |
||
27 | * @since 1.0.5 |
||
28 | * @see https://crowdin.com/page/api/download-glossary |
||
29 | * |
||
30 | * @return \Psr\Http\Message\ResponseInterface |
||
31 | */ |
||
32 | public function download($includeAssigned = true) |
||
37 | |||
38 | /** |
||
39 | * Upload your Translation Memory for Crowdin Project in TMX file format. |
||
40 | * |
||
41 | * @param string $file Full path to file to upload. |
||
42 | * |
||
43 | * @since 1.0.5 |
||
44 | * @see https://crowdin.com/page/api/upload-glossary |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | public function upload($file) |
||
107 | } |
||
108 |
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.