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 PeerStatusChange extends Event |
|
| 31 | { |
||
| 32 | /** |
||
| 33 | * @var Endpoint |
||
| 34 | */ |
||
| 35 | private $endpoint; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var Peer |
||
| 39 | */ |
||
| 40 | private $peer; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return Endpoint |
||
| 44 | */ |
||
| 45 | public function getEndpoint() |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return Peer |
||
| 52 | */ |
||
| 53 | public function getPeer() |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param AriClient $client |
||
| 60 | * @param string $response |
||
| 61 | */ |
||
| 62 | public function __construct(AriClient $client, $response) |
||
| 69 | } |
||
| 70 |