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 | class URLAliasService implements URLAliasServiceInterface |
||
| 19 | { |
||
| 20 | /** @var \eZ\Publish\API\Repository\URLAliasService */ |
||
| 21 | protected $service; |
||
| 22 | |||
| 23 | /** @var LanguageResolver */ |
||
| 24 | protected $languageResolver; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Construct service object from aggregated service and LanguageResolver. |
||
| 28 | * |
||
| 29 | * @param \eZ\Publish\API\Repository\URLAliasService $service |
||
| 30 | * @param LanguageResolver $languageResolver |
||
| 31 | */ |
||
| 32 | public function __construct( |
||
| 39 | |||
| 40 | public function createUrlAlias(Location $location, $path, $languageCode, $forwarding = false, $alwaysAvailable = false) |
||
| 44 | |||
| 45 | public function createGlobalUrlAlias($resource, $path, $languageCode, $forwarding = false, $alwaysAvailable = false) |
||
| 49 | |||
| 50 | View Code Duplication | public function listLocationAliases( |
|
| 65 | |||
| 66 | public function listGlobalAliases($languageCode = null, $offset = 0, $limit = -1) |
||
| 70 | |||
| 71 | public function removeAliases(array $aliasList) |
||
| 75 | |||
| 76 | public function lookup($url, $languageCode = null) |
||
| 80 | |||
| 81 | View Code Duplication | public function reverseLookup( |
|
| 94 | |||
| 95 | public function load($id) |
||
| 99 | } |
||
| 100 |