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 |
||
22 | View Code Duplication | abstract class OnlineTransferSubForm extends AbstractPayoneSubForm |
|
|
|||
23 | { |
||
24 | const PAYMENT_METHOD = 'online_transfer'; |
||
25 | const FIELD_IBAN = 'iban'; |
||
26 | const FIELD_BIC = 'bic'; |
||
27 | const FIELD_BANK_COUNTRY = 'bankcountry'; |
||
28 | const FIELD_BANK_ACCOUNT = 'bankaccount'; |
||
29 | const FIELD_BANK_CODE = 'bankcode'; |
||
30 | const FIELD_BANK_BRANCH_CODE = 'bankbranchcode'; |
||
31 | const FIELD_BANK_CHECK_DIGIT = 'bankcheckdigit'; |
||
32 | const FIELD_ONLINE_BANK_TRANSFER_TYPE = 'onlinebanktransfertype'; |
||
33 | const FIELD_BANK_GROUP_TYPE = 'bankgrouptype'; |
||
34 | const OPTION_BANK_GROUP_TYPES = 'online bank transfer types'; |
||
35 | const OPTION_BANK_COUNTRIES = ''; |
||
36 | |||
37 | /** |
||
38 | * @return string |
||
39 | */ |
||
40 | public function getName() |
||
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | public function getTemplatePath() |
||
52 | |||
53 | /** |
||
54 | * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | public function configureOptions(OptionsResolver $resolver) |
||
68 | |||
69 | /** |
||
70 | * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
||
71 | * |
||
72 | * @return void |
||
73 | */ |
||
74 | public function setDefaultOptions(OptionsResolver $resolver) |
||
78 | |||
79 | /** |
||
80 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
81 | * @param array $options |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
90 | |||
91 | /** |
||
92 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
93 | * |
||
94 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
95 | */ |
||
96 | protected function addBankAccount(FormBuilderInterface $builder) |
||
111 | |||
112 | /** |
||
113 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
114 | * |
||
115 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
116 | */ |
||
117 | protected function addBankCode(FormBuilderInterface $builder) |
||
132 | |||
133 | /** |
||
134 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
135 | * |
||
136 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
137 | */ |
||
138 | protected function addBankBranchCode(FormBuilderInterface $builder) |
||
153 | |||
154 | /** |
||
155 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
156 | * |
||
157 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
158 | */ |
||
159 | protected function addBankCheckDigit(FormBuilderInterface $builder) |
||
174 | |||
175 | /** |
||
176 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
177 | * |
||
178 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
179 | */ |
||
180 | protected function addIban(FormBuilderInterface $builder) |
||
195 | |||
196 | /** |
||
197 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
198 | * @param array $options |
||
199 | * |
||
200 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
201 | */ |
||
202 | protected function addBankCountry(FormBuilderInterface $builder, array $options) |
||
232 | |||
233 | /** |
||
234 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
235 | * |
||
236 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
237 | */ |
||
238 | protected function addBic(FormBuilderInterface $builder) |
||
253 | |||
254 | /** |
||
255 | * @param \Generated\Shared\Transfer\PayonePaymentOnlinetransferTransfer $data |
||
256 | * @param \Symfony\Component\Validator\Context\ExecutionContextInterface $context |
||
257 | * |
||
258 | * @return void |
||
259 | */ |
||
260 | public function checkBankAccount(PayonePaymentOnlinetransferTransfer $data, ExecutionContextInterface $context) |
||
281 | |||
282 | /** |
||
283 | * @param \Symfony\Component\Form\FormBuilderInterface $builder |
||
284 | * @param array $options |
||
285 | * |
||
286 | * @return \SprykerEco\Yves\Payone\Form\OnlineTransferSubForm |
||
287 | */ |
||
288 | abstract public function addOnlineBankTransferType(FormBuilderInterface $builder, array $options); |
||
289 | } |
||
290 |
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.