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 RelationConverter implements Converter |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Factory for current class. |
||
| 21 | * |
||
| 22 | * Note: Class should instead be configured as service if it gains dependencies. |
||
| 23 | * |
||
| 24 | * @return Url |
||
| 25 | */ |
||
| 26 | public static function create() |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Converts data from $value to $storageFieldValue. |
||
| 33 | * |
||
| 34 | * @param \eZ\Publish\SPI\Persistence\Content\FieldValue $value |
||
| 35 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $storageFieldValue |
||
| 36 | */ |
||
| 37 | View Code Duplication | public function toStorageValue(FieldValue $value, StorageFieldValue $storageFieldValue) |
|
| 44 | |||
| 45 | /** |
||
| 46 | * Converts data from $value to $fieldValue. |
||
| 47 | * |
||
| 48 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value |
||
| 49 | * @param \eZ\Publish\SPI\Persistence\Content\FieldValue $fieldValue |
||
| 50 | */ |
||
| 51 | View Code Duplication | public function toFieldValue(StorageFieldValue $value, FieldValue $fieldValue) |
|
| 58 | |||
| 59 | /** |
||
| 60 | * Converts field definition data in $fieldDef into $storageFieldDef. |
||
| 61 | * |
||
| 62 | * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef |
||
| 63 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef |
||
| 64 | */ |
||
| 65 | public function toStorageFieldDefinition(FieldDefinition $fieldDef, StorageFieldDefinition $storageDef) |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Converts field definition data in $storageDef into $fieldDef. |
||
| 76 | * |
||
| 77 | * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageDef |
||
| 78 | * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef |
||
| 79 | */ |
||
| 80 | public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef) |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Returns the name of the index column in the attribute table. |
||
| 95 | * |
||
| 96 | * Returns the name of the index column the datatype uses, which is either |
||
| 97 | * "sort_key_int" or "sort_key_string". This column is then used for |
||
| 98 | * filtering and sorting for this type. |
||
| 99 | * |
||
| 100 | * @return false |
||
| 101 | */ |
||
| 102 | public function getIndexColumn() |
||
| 106 | } |
||
| 107 |