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 |
||
18 | class BusOperationsContextFactory |
||
19 | { |
||
20 | /** |
||
21 | * @param object $message |
||
22 | * @param PublishOptions $options |
||
23 | * @param PipelineStageContext $parentContext |
||
24 | * |
||
25 | * @return OutgoingPublishContext |
||
26 | */ |
||
27 | 2 | View Code Duplication | public function createPublishContext( |
40 | |||
41 | /** |
||
42 | * @param object $message |
||
43 | * @param SendOptions $options |
||
44 | * @param PipelineStageContext $parentContext |
||
45 | * |
||
46 | * @return OutgoingSendContext |
||
47 | */ |
||
48 | 2 | View Code Duplication | public function createSendContext( |
61 | |||
62 | /** |
||
63 | * @param object $message |
||
64 | * @param ReplyOptions $options |
||
65 | * @param IncomingContext $parentContext |
||
66 | * |
||
67 | * @return OutgoingReplyContext |
||
68 | */ |
||
69 | 1 | public function createReplyContext( |
|
82 | |||
83 | /** |
||
84 | * @param string $eventFqcn |
||
85 | * @param SubscribeOptions $options |
||
86 | * @param PipelineStageContext $parentContext |
||
87 | * |
||
88 | * @return SubscribeContext |
||
89 | */ |
||
90 | 1 | public function createSubscribeContext($eventFqcn, SubscribeOptions $options, PipelineStageContext $parentContext) |
|
94 | |||
95 | /** |
||
96 | * @param string $eventFqcn |
||
97 | * @param UnsubscribeOptions $options |
||
98 | * @param PipelineStageContext $parentContext |
||
99 | * |
||
100 | * @return UnsubscribeContext |
||
101 | */ |
||
102 | 1 | public function createUnsubscribeContext( |
|
109 | } |
||
110 |