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 |
||
17 | class ImageAssetConverter implements Converter |
||
18 | { |
||
19 | /** |
||
20 | * Converts data from $value to $storageFieldValue. |
||
21 | * |
||
22 | * @param \eZ\Publish\SPI\Persistence\Content\FieldValue $value |
||
23 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $storageFieldValue |
||
24 | */ |
||
25 | View Code Duplication | public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue) |
|
32 | |||
33 | /** |
||
34 | * Converts data from $value to $fieldValue. |
||
35 | * |
||
36 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value |
||
37 | * @param \eZ\Publish\SPI\Persistence\Content\FieldValue $fieldValue |
||
38 | */ |
||
39 | View Code Duplication | public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue) |
|
46 | |||
47 | /** |
||
48 | * Converts field definition data in $fieldDef into $storageFieldDef. |
||
49 | * |
||
50 | * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef |
||
51 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef |
||
52 | */ |
||
53 | public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef) |
||
56 | |||
57 | /** |
||
58 | * Converts field definition data in $storageDef into $fieldDef. |
||
59 | * |
||
60 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef |
||
61 | * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef |
||
62 | */ |
||
63 | public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef) |
||
66 | |||
67 | /** |
||
68 | * Returns the name of the index column in the attribute table. |
||
69 | * |
||
70 | * Returns the name of the index column the datatype uses, which is either |
||
71 | * "sort_key_int" or "sort_key_string". This column is then used for |
||
72 | * filtering and sorting for this type. |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function getIndexColumn() |
||
80 | } |
||
81 |