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 |
||
| 26 | View Code Duplication | class TextMessageVariable extends Response |
|
| 27 | { |
||
| 28 | /** |
||
| 29 | * @var string A unique key identifying the variable. |
||
| 30 | */ |
||
| 31 | private $key; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var string The value of the variable. |
||
| 35 | */ |
||
| 36 | private $value; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @return string A unique key identifying the variable. |
||
| 40 | */ |
||
| 41 | public function getKey() |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return string The value of the variable. |
||
| 48 | */ |
||
| 49 | public function getValue() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param string $response |
||
| 56 | */ |
||
| 57 | public function __construct($response) |
||
| 64 | |||
| 65 | } |
||
| 66 |