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 |
||
| 25 | class VersioningService extends AbstractBrowserBindingService implements VersioningServiceInterface |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * Reverses the effect of a check-out. |
||
| 29 | * |
||
| 30 | * @param string $repositoryId the identifier for the repository |
||
| 31 | * @param string $objectId the identifier for the PWC |
||
| 32 | * @param ExtensionDataInterface|null $extension |
||
| 33 | */ |
||
| 34 | public function cancelCheckOut($repositoryId, $objectId, ExtensionDataInterface $extension = null) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Checks-in the private working copy (PWC) document. |
||
| 41 | * |
||
| 42 | * @param string $repositoryId the identifier for the repository |
||
| 43 | * @param string $objectId input: the identifier for the PWC, |
||
| 44 | * output: the identifier for the newly created version document |
||
| 45 | * @param boolean $major indicator if the new version should become a major (<code>true</code>) or minor |
||
| 46 | * (<code>false</code>) version |
||
| 47 | * @param PropertiesInterface|null $properties the property values that must be applied to the |
||
| 48 | * newly created document object |
||
| 49 | * @param StreamInterface|null $contentStream the content stream that must be stored |
||
| 50 | * for the newly created document object |
||
| 51 | * @param string|null $checkinComment a version comment |
||
| 52 | * @param string[] $policies a list of policy IDs that must be applied to the newly created document object |
||
| 53 | * @param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object |
||
| 54 | * @param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object |
||
| 55 | * @param ExtensionDataInterface|null $extension |
||
| 56 | */ |
||
| 57 | public function checkIn( |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Create a private working copy of the document. |
||
| 74 | * |
||
| 75 | * @param string $repositoryId the identifier for the repository |
||
| 76 | * @param string $objectId input: the identifier for the document that should be checked out, |
||
| 77 | * output: the identifier for the newly created PWC |
||
| 78 | * @param ExtensionDataInterface|null $extension |
||
| 79 | * @param boolean|null $contentCopied output: indicator if the content of the original |
||
| 80 | * document has been copied to the PWC |
||
| 81 | */ |
||
| 82 | public function checkOut( |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Returns the list of all document objects in the specified version series, |
||
| 93 | * sorted by the property "cmis:creationDate" descending. |
||
| 94 | * |
||
| 95 | * @param string $repositoryId the identifier for the repository |
||
| 96 | * @param string $objectId the identifier for the object |
||
| 97 | * @param string $versionSeriesId the identifier for the object |
||
| 98 | * @param string|null $filter a comma-separated list of query names that defines which properties must be |
||
| 99 | * returned by the repository (default is repository specific) |
||
| 100 | * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the allowable |
||
| 101 | * actions for the objects (default is <code>false</code>) |
||
| 102 | * @param ExtensionDataInterface|null $extension |
||
| 103 | * @return ObjectDataInterface[] the complete version history of the version series |
||
| 104 | */ |
||
| 105 | public function getAllVersions( |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Get the latest document object in the version series. |
||
| 118 | * |
||
| 119 | * @param string $repositoryId the identifier for the repository |
||
| 120 | * @param string $objectId |
||
| 121 | * @param string $versionSeriesId |
||
| 122 | * @param boolean $major |
||
| 123 | * @param string|null $filter a comma-separated list of query names that defines which properties must be |
||
| 124 | * returned by the repository (default is repository specific) |
||
| 125 | * @param boolean $includeAllowableActions |
||
| 126 | * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects |
||
| 127 | * participate must be returned (default is <code>IncludeRelationships::NONE</code>) |
||
| 128 | * @param string $renditionFilter indicates what set of renditions the repository must return whose kind |
||
| 129 | * matches this filter (default is "cmis:none") |
||
| 130 | * @param boolean $includePolicyIds if <code>true</code>, then the repository must return the policy ids for |
||
| 131 | * the object (default is <code>false</code>) |
||
| 132 | * @param boolean $includeAcl if <code>true</code>, then the repository must return the ACL for the object |
||
| 133 | * (default is <code>false</code>) |
||
| 134 | * @param ExtensionDataInterface|null $extension |
||
| 135 | * @return ObjectDataInterface |
||
| 136 | */ |
||
| 137 | View Code Duplication | public function getObjectOfLatestVersion( |
|
| 152 | |||
| 153 | /** |
||
| 154 | * Get a subset of the properties for the latest document object in the version series. |
||
| 155 | * |
||
| 156 | * @param string $repositoryId the identifier for the repository |
||
| 157 | * @param string $objectId The identifier for the object |
||
| 158 | * @param string $versionSeriesId The identifier for the version series. |
||
| 159 | * @param boolean $major If <code>true</code>, then the repository MUST return the properties for the latest |
||
| 160 | * major version object in the version series. |
||
| 161 | * If <code>false</code>, the repository MUST return the properties for the latest |
||
| 162 | * (major or non-major) version object in the version series. |
||
| 163 | * @param string|null $filter a comma-separated list of query names that defines which properties must be |
||
| 164 | * returned by the repository (default is repository specific) |
||
| 165 | * @param ExtensionDataInterface|null $extension |
||
| 166 | * @return PropertiesInterface |
||
| 167 | */ |
||
| 168 | public function getPropertiesOfLatestVersion( |
||
| 178 | } |
||
| 179 |