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 |
||
| 28 | final class Repository implements RepositoryInterface |
||
| 29 | { |
||
| 30 | /** |
||
| 31 | * @var \eZ\Publish\API\Repository\Repository |
||
| 32 | */ |
||
| 33 | private $repository; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @var \eZ\Publish\API\Repository\BookmarkService |
||
| 37 | */ |
||
| 38 | private $bookmarkService; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @var \eZ\Publish\API\Repository\ContentService |
||
| 42 | */ |
||
| 43 | private $contentService; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @var \eZ\Publish\API\Repository\ContentTypeService |
||
| 47 | */ |
||
| 48 | private $contentTypeService; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @var \eZ\Publish\API\Repository\FieldTypeService |
||
| 52 | */ |
||
| 53 | private $fieldTypeService; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @var \eZ\Publish\API\Repository\LanguageService |
||
| 57 | */ |
||
| 58 | private $languageService; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @var \eZ\Publish\API\Repository\LocationService |
||
| 62 | */ |
||
| 63 | private $locationService; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @var \eZ\Publish\API\Repository\NotificationService |
||
| 67 | */ |
||
| 68 | private $notificationService; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @var \eZ\Publish\API\Repository\ObjectStateService |
||
| 72 | */ |
||
| 73 | private $objectStateService; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @var \eZ\Publish\API\Repository\RoleService |
||
| 77 | */ |
||
| 78 | private $roleService; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @var \eZ\Publish\API\Repository\SearchService |
||
| 82 | */ |
||
| 83 | private $searchService; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @var \eZ\Publish\API\Repository\SectionService |
||
| 87 | */ |
||
| 88 | private $sectionService; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @var \eZ\Publish\API\Repository\TrashService |
||
| 92 | */ |
||
| 93 | private $trashService; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var \eZ\Publish\API\Repository\URLAliasService |
||
| 97 | */ |
||
| 98 | private $urlAliasService; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @var \eZ\Publish\API\Repository\URLService |
||
| 102 | */ |
||
| 103 | private $urlService; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @var \eZ\Publish\API\Repository\URLWildcardService |
||
| 107 | */ |
||
| 108 | private $urlWildcardService; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @var \eZ\Publish\API\Repository\UserPreferenceService |
||
| 112 | */ |
||
| 113 | private $userPreferenceService; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @var \eZ\Publish\API\Repository\UserService |
||
| 117 | */ |
||
| 118 | private $userService; |
||
| 119 | |||
| 120 | View Code Duplication | public function __construct( |
|
| 159 | |||
| 160 | public function getCurrentUser(): User |
||
| 164 | |||
| 165 | public function getCurrentUserReference(): UserReference |
||
| 169 | |||
| 170 | public function setCurrentUser(UserReference $user): void |
||
| 174 | |||
| 175 | public function hasAccess($module, $function, UserReference $user = null) |
||
| 179 | |||
| 180 | public function canUser($module, $function, ValueObject $object, $targets = null): bool |
||
| 184 | |||
| 185 | public function sudo(callable $callback, RepositoryInterface $outerRepository = null) |
||
| 189 | |||
| 190 | public function beginTransaction(): void |
||
| 194 | |||
| 195 | public function commit(): void |
||
| 199 | |||
| 200 | public function rollback(): void |
||
| 204 | |||
| 205 | public function getPermissionResolver(): PermissionResolver |
||
| 209 | |||
| 210 | public function getBookmarkService(): BookmarkServiceInterface |
||
| 214 | |||
| 215 | public function getContentService(): ContentServiceInterface |
||
| 219 | |||
| 220 | public function getContentTypeService(): ContentTypeServiceInterface |
||
| 224 | |||
| 225 | public function getFieldTypeService(): FieldTypeServiceInterface |
||
| 229 | |||
| 230 | public function getContentLanguageService(): LanguageServiceInterface |
||
| 234 | |||
| 235 | public function getLocationService(): LocationServiceInterface |
||
| 239 | |||
| 240 | public function getNotificationService(): NotificationServiceInterface |
||
| 244 | |||
| 245 | public function getObjectStateService(): ObjectStateServiceInterface |
||
| 249 | |||
| 250 | public function getRoleService(): RoleServiceInterface |
||
| 254 | |||
| 255 | public function getSearchService(): SearchServiceInterface |
||
| 259 | |||
| 260 | public function getSectionService(): SectionServiceInterface |
||
| 264 | |||
| 265 | public function getTrashService(): TrashServiceInterface |
||
| 269 | |||
| 270 | public function getURLAliasService(): URLAliasServiceInterface |
||
| 274 | |||
| 275 | public function getURLService(): URLServiceInterface |
||
| 279 | |||
| 280 | public function getURLWildcardService(): URLWildcardServiceInterface |
||
| 284 | |||
| 285 | public function getUserPreferenceService(): UserPreferenceServiceInterface |
||
| 289 | |||
| 290 | public function getUserService(): UserServiceInterface |
||
| 294 | } |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.