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 |
||
5 | class Job extends \Dtc\QueueBundle\Model\Job |
||
6 | { |
||
7 | protected $deliveryTag; |
||
8 | |||
9 | /** |
||
10 | * @return mixed |
||
11 | */ |
||
12 | public function getDeliveryTag() |
||
16 | |||
17 | /** |
||
18 | * @param mixed $deliveryTag |
||
19 | */ |
||
20 | public function setDeliveryTag($deliveryTag) |
||
24 | |||
25 | /** |
||
26 | * @return string A json_encoded version of a queueable version of the object |
||
27 | */ |
||
28 | View Code Duplication | public function toMessage() |
|
40 | |||
41 | /** |
||
42 | * @param string $message a json_encoded version of the object |
||
43 | */ |
||
44 | View Code Duplication | public function fromMessage($message) |
|
58 | } |
||
59 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.