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 SearchService implements SearchServiceInterface |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Aggregated service. |
||
| 24 | * |
||
| 25 | * @var \eZ\Publish\API\Repository\SearchService |
||
| 26 | */ |
||
| 27 | protected $service; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Language resolver |
||
| 31 | * |
||
| 32 | * @var LanguageResolver |
||
| 33 | */ |
||
| 34 | protected $languageResolver; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Construct service object from aggregated service and LanguageResolver. |
||
| 38 | * |
||
| 39 | * @param \eZ\Publish\API\Repository\SearchService $service |
||
| 40 | * @param LanguageResolver $languageResolver |
||
| 41 | */ |
||
| 42 | public function __construct( |
||
| 49 | |||
| 50 | View Code Duplication | public function findContent(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 58 | |||
| 59 | View Code Duplication | public function findContentInfo(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 67 | |||
| 68 | View Code Duplication | public function findSingle(Criterion $filter, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 76 | |||
| 77 | public function suggest($prefix, $fieldPaths = array(), $limit = 10, Criterion $filter = null) |
||
| 81 | |||
| 82 | View Code Duplication | public function findLocations(LocationQuery $query, array $languageFilter = array(), $filterOnUserPermissions = true) |
|
| 90 | } |
||
| 91 |