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 |
||
| 11 | View Code Duplication | class CronEvent extends MessageQueueEvent implements PushViaWebsocket |
|
| 12 | { |
||
| 13 | use JsonSerializableTrait; |
||
| 14 | |||
| 15 | const CRON = 'message_queue.cron'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | private $expression; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param AbstractEvent $event |
||
| 24 | * @param string $expression |
||
| 25 | */ |
||
| 26 | 3 | public function __construct(AbstractEvent $event, string $expression) |
|
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | 3 | public function getExpression() : string |
|
| 41 | } |
||
| 42 |