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 ContentLanguageHandler extends AbstractInMemoryHandler implements ContentLanguageHandlerInterface |
||
19 | { |
||
20 | /** @var callable */ |
||
21 | private $getTags; |
||
22 | |||
23 | /** @var callable */ |
||
24 | private $getKeys; |
||
25 | |||
26 | /** |
||
27 | * Set callback functions for use in cache retrieval. |
||
28 | * |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | public function __construct(...$params) |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | View Code Duplication | public function create(CreateStruct $struct) |
|
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function update(Language $struct) |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | View Code Duplication | public function load($id) |
|
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | View Code Duplication | public function loadList(array $ids): iterable |
|
103 | |||
104 | /** |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | View Code Duplication | public function loadByLanguageCode($languageCode) |
|
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | View Code Duplication | public function loadListByLanguageCodes(array $languageCodes): iterable |
|
135 | |||
136 | /** |
||
137 | * {@inheritdoc} |
||
138 | */ |
||
139 | public function loadAll() |
||
150 | |||
151 | /** |
||
152 | * {@inheritdoc} |
||
153 | */ |
||
154 | View Code Duplication | public function delete($id) |
|
164 | } |
||
165 |