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 ChannelDtmfReceived extends Event implements IdentifiableEventInterface |
|
| 31 | { |
||
| 32 | /** |
||
| 33 | * @var Channel The channel on which DTMF was received |
||
| 34 | */ |
||
| 35 | private $channel; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var string DTMF digit received (0-9, A-E, # or *) |
||
| 39 | */ |
||
| 40 | private $digit; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var int Number of milliseconds DTMF was received |
||
| 44 | */ |
||
| 45 | private $durationMs; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @return Channel |
||
| 49 | */ |
||
| 50 | public function getChannel() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return string DTMF digit received (0-9, A-E, # or *) |
||
| 57 | */ |
||
| 58 | public function getDigit() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @return int Number of milliseconds DTMF was received |
||
| 65 | */ |
||
| 66 | public function getDurationMs() |
||
| 70 | |||
| 71 | public function getEventId() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param AriClient $client |
||
| 78 | * @param string $response |
||
| 79 | */ |
||
| 80 | public function __construct(AriClient $client, $response) |
||
| 88 | |||
| 89 | } |
||
| 90 |