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 |
||
13 | View Code Duplication | class SuccessfulPayment extends BaseType |
|
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | static protected $requiredParams = ['currency', 'total_amount', 'invoice_payload', 'telegram_payment_charge_id', 'provider_payment_charge_id']; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | static protected $map = [ |
||
24 | 'currency' => true, |
||
25 | 'total_amount' => true, |
||
26 | 'invoice_payload' => true, |
||
27 | 'shipping_option_id' => true, |
||
28 | 'order_info' => OrderInfo::class, |
||
29 | 'telegram_payment_charge_id' => true, |
||
30 | 'provider_payment_charge_id' => true |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * Three-letter ISO 4217 currency code |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $currency; |
||
39 | |||
40 | /** |
||
41 | * Total price in the smallest units of the currency |
||
42 | * |
||
43 | * @var integer |
||
44 | */ |
||
45 | protected $totalAmount; |
||
46 | |||
47 | /** |
||
48 | * Bot specified invoice payload |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $invoicePayload; |
||
53 | |||
54 | /** |
||
55 | * Optional. Identifier of the shipping option chosen by the user |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $shippingOptionId; |
||
60 | |||
61 | /** |
||
62 | * Optional. Order info provided by the user |
||
63 | * |
||
64 | * @var OrderInfo |
||
65 | */ |
||
66 | protected $orderInfo; |
||
67 | |||
68 | /** |
||
69 | * Telegram payment identifier |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $telegramPaymentChargeId; |
||
74 | |||
75 | /** |
||
76 | * Provider payment identifier |
||
77 | * |
||
78 | * @var string |
||
79 | */ |
||
80 | protected $providerPaymentChargeId; |
||
81 | |||
82 | /** |
||
83 | * @author MY |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getCurrency() |
||
90 | |||
91 | /** |
||
92 | * @author MY |
||
93 | * @param string $currency |
||
94 | */ |
||
95 | public function setCurrency($currency) |
||
99 | |||
100 | /** |
||
101 | * @author MY |
||
102 | * @return int |
||
103 | */ |
||
104 | public function getTotalAmount() |
||
108 | |||
109 | /** |
||
110 | * @author MY |
||
111 | * @param int $totalAmount |
||
112 | */ |
||
113 | public function setTotalAmount($totalAmount) |
||
117 | |||
118 | /** |
||
119 | * @author MY |
||
120 | * @return array |
||
121 | */ |
||
122 | public function getInvoicePayload() |
||
126 | |||
127 | /** |
||
128 | * @author MY |
||
129 | * @param array $invoicePayload |
||
130 | */ |
||
131 | public function setInvoicePayload($invoicePayload) |
||
135 | |||
136 | /** |
||
137 | * @author MY |
||
138 | * @return string |
||
139 | */ |
||
140 | public function getShippingOptionId() |
||
144 | |||
145 | /** |
||
146 | * @author MY |
||
147 | * @param string $shippingOptionId |
||
148 | */ |
||
149 | public function setShippingOptionId($shippingOptionId) |
||
153 | |||
154 | /** |
||
155 | * @author MY |
||
156 | * @return string |
||
157 | */ |
||
158 | public function getTelegramPaymentChargeId() |
||
162 | |||
163 | /** |
||
164 | * @author MY |
||
165 | * @param string $telegramPaymentChargeId |
||
166 | */ |
||
167 | public function setTelegramPaymentChargeId($telegramPaymentChargeId) |
||
171 | |||
172 | /** |
||
173 | * @author MY |
||
174 | * @return mixed |
||
175 | */ |
||
176 | public function getProviderPaymentChargeId() |
||
180 | |||
181 | /** |
||
182 | * @author MY |
||
183 | * @param mixed $providerPaymentChargeId |
||
184 | */ |
||
185 | public function setProviderPaymentChargeId($providerPaymentChargeId) |
||
189 | |||
190 | /** |
||
191 | * @author MY |
||
192 | * @return OrderInfo |
||
193 | */ |
||
194 | public function getOrderInfo() |
||
198 | |||
199 | /** |
||
200 | * @author MY |
||
201 | * @param OrderInfo $orderInfo |
||
202 | */ |
||
203 | public function setOrderInfo($orderInfo) |
||
207 | } |
||
208 |