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 |
||
20 | Class Memory extends Package |
||
21 | { |
||
22 | /** |
||
23 | * Download Crowdin project Translation Memory as TMX file. |
||
24 | * |
||
25 | * @param string $toPath Export to path. |
||
26 | * @param boolean $includeAssigned Defines whether the assigned TMs should be included in downloaded TMX file. |
||
27 | * Acceptable values are: 0, 1. |
||
28 | * Default is 1. |
||
29 | * @param boolean $sourceLanguage Defines a source language for language pair. Сrowdin language code should be used. |
||
30 | * @param boolean $targetLanguage Defines a target language for language pair. Сrowdin language code should be used. |
||
31 | * |
||
32 | * @since 1.0.5 |
||
33 | * @see https://crowdin.com/page/api/download-tm |
||
34 | * |
||
35 | * @return ResponseInterface |
||
36 | */ |
||
37 | public function download(string $toPath, bool $includeAssigned = true, string $sourceLanguage = '', string $targetLanguage = '') : ResponseInterface |
||
52 | |||
53 | /** |
||
54 | * Upload your Translation Memory for Crowdin Project in TMX file format. |
||
55 | * |
||
56 | * @param string $file Full path to file to upload. |
||
57 | * |
||
58 | * @since 1.0.5 |
||
59 | * @see https://crowdin.com/page/api/upload-tm |
||
60 | * |
||
61 | * @return ResponseInterface |
||
62 | */ |
||
63 | 2 | View Code Duplication | public function upload(string $file) : ResponseInterface |
78 | } |
||
79 |
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.