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 |
||
8 | class BusContext implements BusContextInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var PipelineRootStageContext |
||
12 | */ |
||
13 | private $rootContext; |
||
14 | |||
15 | /** |
||
16 | * @var BusOperations |
||
17 | */ |
||
18 | private $busOperations; |
||
19 | |||
20 | /** |
||
21 | * @var OutgoingOptionsFactory |
||
22 | */ |
||
23 | private $outgoingOptionsFactory; |
||
24 | |||
25 | /** |
||
26 | * @param PipelineRootStageContext $rootContext |
||
27 | * @param BusOperations $busOperations |
||
28 | * @param OutgoingOptionsFactory $outgoingOptionsFactory |
||
29 | */ |
||
30 | 10 | public function __construct( |
|
39 | |||
40 | /** |
||
41 | * @param object $message |
||
42 | * @param SendOptions|null $options |
||
43 | */ |
||
44 | 3 | public function send($message, SendOptions $options = null) |
|
50 | |||
51 | /** |
||
52 | * @param object $message |
||
53 | * @param SendOptions|null $options |
||
54 | */ |
||
55 | 1 | View Code Duplication | public function sendLocal($message, SendOptions $options = null) |
62 | |||
63 | /** |
||
64 | * @param object $message |
||
65 | * @param PublishOptions|null $options |
||
66 | */ |
||
67 | 2 | public function publish($message, PublishOptions $options = null) |
|
73 | |||
74 | /** |
||
75 | * @param string $eventFqcn |
||
76 | * @param SubscribeOptions|null $options |
||
77 | */ |
||
78 | 2 | public function subscribe($eventFqcn, SubscribeOptions $options = null) |
|
84 | |||
85 | /** |
||
86 | * @param string $eventFqcn |
||
87 | * @param UnsubscribeOptions|null $options |
||
88 | */ |
||
89 | 2 | public function unsubscribe($eventFqcn, UnsubscribeOptions $options = null) |
|
95 | } |
||
96 |