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 |
||
| 33 | View Code Duplication | class Equals extends OrmCriteria |
|
|
|
|||
| 34 | { |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var OrmProperty |
||
| 38 | */ |
||
| 39 | private $propertyName; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var mixed |
||
| 43 | */ |
||
| 44 | private $expression; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Initializes an Equals operator matching the given <code>property</code> against the given |
||
| 48 | * <code>expression</code>. |
||
| 49 | * |
||
| 50 | * @param OrmProperty $property The property to match |
||
| 51 | * @param mixed $expression The expression to match against. May be <code>null</code>. |
||
| 52 | */ |
||
| 53 | 4 | public function __construct(OrmProperty $property, $expression) |
|
| 58 | |||
| 59 | 4 | public function parse($entryKey, &$whereClause, ParameterRegistry $parameters) |
|
| 74 | |||
| 75 | } |
||
| 76 |
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.