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 |
||
| 9 | class EzRichText extends AbstractFieldHandler implements FieldValueImporterInterface |
||
| 10 | { |
||
| 11 | protected $resolver; |
||
| 12 | |||
| 13 | public function __construct(PrefixBasedResolverInterface $resolver) |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Replaces any references in an xml string to be used as the input data for an ezrichtext field. |
||
| 20 | * |
||
| 21 | * @param string|array $fieldValue The definition of teh field value, structured in the yml file. Either a string, or an array with key 'content' |
||
| 22 | * @param array $context The context for execution of the current migrations. Contains f.e. the path to the migration |
||
| 23 | * @return string |
||
| 24 | * |
||
| 25 | * @todo replace objects and location refs in ezcontent:// and ezlocation:// links |
||
| 26 | */ |
||
| 27 | public function hashToFieldValue($fieldValue, array $context = array()) |
||
| 53 | } |
||
| 54 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.