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 |
||
| 23 | View Code Duplication | class BitNot implements Operand |
|
| 24 | { |
||
| 25 | /** |
||
| 26 | * @var Operand|string |
||
| 27 | */ |
||
| 28 | private $field; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param Operand|string $field |
||
| 32 | */ |
||
| 33 | public function __construct($field) |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param QueryBuilder $qb |
||
| 40 | * @param string $dqlAlias |
||
| 41 | * |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | public function transform(QueryBuilder $qb, $dqlAlias) |
||
| 52 | } |
||
| 53 |
If you suppress an error, we recommend checking for the error condition explicitly: