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 |
||
13 | class Mapper |
||
14 | { |
||
15 | /** |
||
16 | * Extracts UserPreference objects from $rows. |
||
17 | * |
||
18 | * @param array $rows |
||
19 | * |
||
20 | * @return \eZ\Publish\SPI\Persistence\UserPreference\UserPreference[] |
||
21 | */ |
||
22 | public function extractUserPreferencesFromRows(array $rows): array |
||
31 | |||
32 | /** |
||
33 | * Extract UserPreference object from $row. |
||
34 | * |
||
35 | * @param array $row |
||
36 | * |
||
37 | * @return \eZ\Publish\SPI\Persistence\UserPreference\UserPreference |
||
38 | */ |
||
39 | View Code Duplication | private function extractUserPreferenceFromRow(array $row): UserPreference |
|
49 | } |
||
50 |