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 |
||
12 | class EcommercePayment_Stripe_ChargeRecordedCustomer extends EcommercePayment_Stripe |
||
|
|||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Perform payment processing for the type of |
||
17 | * payment. For example, if this was a credit card |
||
18 | * payment type, you would perform the data send |
||
19 | * off to the payment gateway on this function for |
||
20 | * your payment subclass. |
||
21 | * |
||
22 | * This is used by {@link OrderForm} when it is |
||
23 | * submitted. |
||
24 | * |
||
25 | * @param array $data The form request data - see OrderForm |
||
26 | * @param OrderForm $form The form object submitted on |
||
27 | * |
||
28 | * @return EcommercePaymentResult |
||
29 | */ |
||
30 | View Code Duplication | public function processPayment($data, $form) |
|
73 | } |
||
74 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.