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 |
||
| 20 | class In implements Filter |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @deprecated This property will be marked as private in 2.0. |
||
| 24 | * |
||
| 25 | * @var Operand|string |
||
| 26 | */ |
||
| 27 | protected $field; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @deprecated This property will be marked as private in 2.0. |
||
| 31 | * |
||
| 32 | * @var Operand|mixed |
||
| 33 | */ |
||
| 34 | protected $value; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @deprecated This property will be marked as private in 2.0. |
||
| 38 | * |
||
| 39 | * @var string|null |
||
| 40 | */ |
||
| 41 | protected $dqlAlias; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Make sure the $field has a value equals to $value. |
||
| 45 | * |
||
| 46 | * @param Operand|string $field |
||
| 47 | * @param Operand|mixed $value |
||
| 48 | * @param string|null $dqlAlias |
||
| 49 | */ |
||
| 50 | public function __construct($field, $value, $dqlAlias = null) |
||
| 51 | { |
||
| 52 | $this->field = $field; |
||
|
|
|||
| 53 | $this->value = $value; |
||
| 54 | $this->dqlAlias = $dqlAlias; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param QueryBuilder $qb |
||
| 59 | * @param string $dqlAlias |
||
| 60 | * |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | View Code Duplication | public function getFilter(QueryBuilder $qb, $dqlAlias) |
|
| 77 | } |
||
| 78 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.