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 MultiFilingService extends AbstractBrowserBindingService implements MultiFilingServiceInterface |
||
21 | { |
||
22 | /** |
||
23 | * Adds an existing fileable non-folder object to a folder. |
||
24 | * |
||
25 | * @param string $repositoryId The identifier for the repository. |
||
26 | * @param string $objectId The identifier for the object. |
||
27 | * @param string $folderId The folder into which the object is to be filed. |
||
28 | * @param boolean $allVersions Add all versions of the object to the folder if the repository |
||
29 | * supports version-specific filing. Defaults to <code>true</code>. |
||
30 | * @param ExtensionDataInterface|null $extension |
||
31 | */ |
||
32 | public function addObjectToFolder( |
||
51 | |||
52 | /** |
||
53 | * Removes an existing fileable non-folder object from a folder. |
||
54 | * |
||
55 | * @param string $repositoryId The identifier for the repository. |
||
56 | * @param string $objectId The identifier for the object. |
||
57 | * @param string|null $folderId The folder from which the object is to be removed. |
||
58 | * If no value is specified, then the repository MUST remove the object from all folders in which it is |
||
59 | * currently filed. |
||
60 | * @param ExtensionDataInterface|null $extension |
||
61 | */ |
||
62 | View Code Duplication | public function removeObjectFromFolder( |
|
79 | } |
||
80 |
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.