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 |
||
16 | trait AggregateEventsRaiseInSelfTrait |
||
17 | { |
||
18 | /** |
||
19 | * @var EventInterface[] |
||
20 | */ |
||
21 | private $events = []; |
||
22 | |||
23 | /** |
||
24 | * @deprecated It will be removed in 2.0 |
||
25 | * |
||
26 | * @var EventNameResolverInterface |
||
27 | */ |
||
28 | private $resolver; |
||
29 | |||
30 | /** |
||
31 | * @deprecated It will be removed in 2.0. If you want change the event name resolver, you must override getMethodNameFromEvent() method. |
||
32 | * @see AggregateEventsRaiseInSelfTrait::getMethodNameFromEvent() |
||
33 | * @codeCoverageIgnore |
||
34 | * |
||
35 | * @param EventNameResolverInterface $resolver |
||
36 | */ |
||
37 | protected function changeEventNameResolver(EventNameResolverInterface $resolver) |
||
43 | |||
44 | /** |
||
45 | * @param EventInterface $event |
||
46 | */ |
||
47 | 2 | View Code Duplication | private function raiseInSelf(EventInterface $event) |
56 | |||
57 | /** |
||
58 | * @param EventInterface $event |
||
59 | */ |
||
60 | 2 | protected function raise(EventInterface $event) |
|
65 | |||
66 | /** |
||
67 | * @return EventInterface[] |
||
68 | */ |
||
69 | 2 | public function pullEvents() |
|
76 | |||
77 | /** |
||
78 | * Get handler method name from event. |
||
79 | * |
||
80 | * Override this method if you want to change algorithm to generate the handler method name. |
||
81 | * |
||
82 | * @param EventInterface $event |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 2 | protected function getMethodNameFromEvent(EventInterface $event) |
|
95 | } |
||
96 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.