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 |
||
36 | class SofortUeberweisung extends OnlineBankTransferBase |
||
37 | { |
||
38 | /** |
||
39 | * Payment method code |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $_code = PayoneConfig::METHOD_OBT_SOFORTUEBERWEISUNG; |
||
44 | |||
45 | /** |
||
46 | * Payment method sub type |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $sSubType = self::METHOD_OBT_SUBTYPE_SOFORTUEBERWEISUNG; |
||
51 | |||
52 | /** |
||
53 | * Return parameters specific to this payment sub type |
||
54 | * |
||
55 | * @param Order $oOrder |
||
56 | * @return array |
||
57 | */ |
||
58 | public function getSubTypeSpecificParameters(Order $oOrder) |
||
72 | |||
73 | /** |
||
74 | * Add the checkout-form-data to the checkout session |
||
75 | * |
||
76 | * @param DataObject $data |
||
77 | * @return $this |
||
78 | */ |
||
79 | View Code Duplication | public function assignData(DataObject $data) |
|
89 | } |
||
90 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.