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 |
||
| 7 | class OutboxTransportOperation |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $messageId; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | private $options; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $body; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var array |
||
| 26 | */ |
||
| 27 | private $headers; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param string $messageId |
||
| 31 | * @param array $options |
||
| 32 | * @param string $body |
||
| 33 | * @param array $headers |
||
| 34 | */ |
||
| 35 | 10 | View Code Duplication | public function __construct($messageId, array $options, $body, array $headers) |
| 44 | |||
| 45 | /** |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | 3 | public function getMessageId() |
|
| 52 | |||
| 53 | /** |
||
| 54 | * @return array |
||
| 55 | */ |
||
| 56 | 3 | public function getOptions() |
|
| 60 | |||
| 61 | /** |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | 3 | public function getBody() |
|
| 68 | |||
| 69 | /** |
||
| 70 | * @return array |
||
| 71 | */ |
||
| 72 | 3 | public function getHeaders() |
|
| 76 | } |
||
| 77 |