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 Installment extends PayolutionBase |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * Payment method code |
||
| 40 | * |
||
| 41 | * @var string |
||
| 42 | */ |
||
| 43 | protected $_code = PayoneConfig::METHOD_PAYOLUTION_INSTALLMENT; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Payment method sub type |
||
| 47 | * |
||
| 48 | * @var string |
||
| 49 | */ |
||
| 50 | protected $sSubType = self::METHOD_PAYOLUTION_SUBTYPE_INSTALLMENT; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Payment method long sub type |
||
| 54 | * |
||
| 55 | * @var string|bool |
||
| 56 | */ |
||
| 57 | protected $sLongSubType = 'Payolution-Installment'; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Returns authorization-mode |
||
| 61 | * Barzahlen only supports preauthorization |
||
| 62 | * |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | public function getAuthorizationMode() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Return parameters specific to this payment sub type |
||
| 72 | * |
||
| 73 | * @param Order $oOrder |
||
| 74 | * @return array |
||
| 75 | */ |
||
| 76 | View Code Duplication | public function getSubTypeSpecificParameters(Order $oOrder) |
|
| 89 | |||
| 90 | /** |
||
| 91 | * Add the checkout-form-data to the checkout session |
||
| 92 | * |
||
| 93 | * @param DataObject $data |
||
| 94 | * @return $this |
||
| 95 | */ |
||
| 96 | View Code Duplication | public function assignData(DataObject $data) |
|
| 107 | } |
||
| 108 |
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.