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 SafeInvoice extends PayoneMethod |
||
37 | { |
||
38 | /** |
||
39 | * Payment method code |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $_code = PayoneConfig::METHOD_SAFE_INVOICE; |
||
44 | |||
45 | /** |
||
46 | * Clearingtype for PAYONE authorization request |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $sClearingtype = 'rec'; |
||
51 | |||
52 | /** |
||
53 | * Return parameters specific to this payment type |
||
54 | * |
||
55 | * @param Order $oOrder |
||
56 | * @return array |
||
57 | */ |
||
58 | public function getPaymentSpecificParameters(Order $oOrder) |
||
68 | |||
69 | /** |
||
70 | * Returns formatted birthday if possible |
||
71 | * |
||
72 | * @param DataObject $data |
||
73 | * @return string|false |
||
74 | */ |
||
75 | View Code Duplication | protected function getFormattedBirthday(DataObject $data) |
|
91 | |||
92 | /** |
||
93 | * Add the checkout-form-data to the checkout session |
||
94 | * |
||
95 | * @param DataObject $data |
||
96 | * @return $this |
||
97 | */ |
||
98 | public function assignData(DataObject $data) |
||
110 | } |
||
111 |
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.