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 SesApiService extends BaseApiService |
||
9 | { |
||
10 | private $eventAssoc = [ |
||
11 | 'permanent_bounce' => SwmMailHookEvent::MAILHOOK_HARDBOUNCE, |
||
12 | 'transient_bounce' => SwmMailHookEvent::MAILHOOK_SOFTBOUNCE, |
||
13 | 'undetermined_bounce' => SwmMailHookEvent::MAILHOOK_SOFTBOUNCE, |
||
14 | 'spam_complaint' => SwmMailHookEvent::MAILHOOK_SPAM, |
||
15 | 'delivery' => SwmMailHookEvent::MAILHOOK_SEND, |
||
16 | ]; |
||
17 | |||
18 | const SNS_BOUNCE = 'Bounce'; |
||
19 | const SNS_COMPLAINT = 'Complaint'; |
||
20 | const SNS_DELIVERY = 'Delivery'; |
||
21 | |||
22 | /** |
||
23 | * @throws \Exception |
||
24 | * |
||
25 | * @return array<HookInterface> |
||
26 | */ |
||
27 | public function bind() |
||
70 | } |
||
71 |
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.