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 | /** |
||
| 21 | * Aggregated service. |
||
| 22 | * |
||
| 23 | * @var \eZ\Publish\API\Repository\URLAliasService |
||
| 24 | */ |
||
| 25 | protected $service; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Language resolver |
||
| 29 | * |
||
| 30 | * @var LanguageResolver |
||
| 31 | */ |
||
| 32 | protected $languageResolver; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Construct service object from aggregated service and LanguageResolver. |
||
| 36 | * |
||
| 37 | * @param \eZ\Publish\API\Repository\URLAliasService $service |
||
| 38 | * @param LanguageResolver $languageResolver |
||
| 39 | */ |
||
| 40 | public function __construct( |
||
| 47 | |||
| 48 | public function createUrlAlias(Location $location, $path, $languageCode, $forwarding = false, $alwaysAvailable = false) |
||
| 52 | |||
| 53 | public function createGlobalUrlAlias($resource, $path, $languageCode, $forwarding = false, $alwaysAvailable = false) |
||
| 57 | |||
| 58 | View Code Duplication | public function listLocationAliases( |
|
| 75 | |||
| 76 | public function listGlobalAliases($languageCode = null, $offset = 0, $limit = -1) |
||
| 80 | |||
| 81 | public function removeAliases(array $aliasList) |
||
| 85 | |||
| 86 | public function lookup($url, $languageCode = null) |
||
| 90 | |||
| 91 | View Code Duplication | public function reverseLookup( |
|
| 106 | |||
| 107 | public function load($id) |
||
| 111 | } |
||
| 112 |