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 |
||
| 30 | View Code Duplication | class TextMessageReceived extends Event |
|
| 31 | { |
||
| 32 | /** |
||
| 33 | * @var Endpoint (optional) |
||
| 34 | */ |
||
| 35 | private $endpoint; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var TextMessage |
||
| 39 | */ |
||
| 40 | private $message; |
||
| 41 | |||
| 42 | public function getEndpoint() |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return TextMessage |
||
| 49 | */ |
||
| 50 | public function getMessage() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param AriClient $client |
||
| 57 | * @param string $response |
||
| 58 | */ |
||
| 59 | public function __construct(AriClient $client, $response) |
||
| 66 | } |
||
| 67 |