Complex classes like CardDirectPayIn often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CardDirectPayIn, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
15 | class CardDirectPayIn |
||
16 | { |
||
17 | private $resourceId; |
||
18 | |||
19 | private $tag; |
||
20 | |||
21 | private $authorId; |
||
22 | |||
23 | private $creditedUserId; |
||
24 | |||
25 | private $creditedWalletId; |
||
26 | |||
27 | private $debitedFunds; |
||
28 | |||
29 | private $fees; |
||
30 | |||
31 | private $feesCurrency; |
||
32 | |||
33 | private $secureModeReturnUrl; |
||
34 | |||
35 | private $cardId; |
||
36 | |||
37 | private $secureMode; |
||
38 | |||
39 | private $secureModeNeeded; |
||
40 | |||
41 | private $secureModeRedirectUrl; |
||
42 | |||
43 | private $statementDescriptor; |
||
44 | |||
45 | private $amount; |
||
46 | |||
47 | private $currency; |
||
48 | |||
49 | private $cardType; |
||
50 | |||
51 | private $status; |
||
52 | |||
53 | private $resultCode; |
||
54 | |||
55 | private $resultMessage; |
||
56 | |||
57 | /** |
||
58 | * @return mixed |
||
59 | */ |
||
60 | public function getTag() |
||
64 | |||
65 | /** |
||
66 | * @param mixed $tag |
||
67 | */ |
||
68 | public function setTag($tag) |
||
72 | |||
73 | /** |
||
74 | * @return mixed |
||
75 | */ |
||
76 | public function getAuthorId() |
||
80 | |||
81 | /** |
||
82 | * @param mixed $authorId |
||
83 | */ |
||
84 | public function setAuthorId($authorId) |
||
88 | |||
89 | /** |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function getCreditedUserId() |
||
96 | |||
97 | /** |
||
98 | * @param mixed $creditedUserId |
||
99 | */ |
||
100 | public function setCreditedUserId($creditedUserId) |
||
104 | |||
105 | /** |
||
106 | * @return mixed |
||
107 | */ |
||
108 | public function getCreditedWalletId() |
||
112 | |||
113 | /** |
||
114 | * @param mixed $creditedWalletId |
||
115 | */ |
||
116 | public function setCreditedWalletId($creditedWalletId) |
||
120 | |||
121 | /** |
||
122 | * @return mixed |
||
123 | */ |
||
124 | public function getDebitedFunds() |
||
128 | |||
129 | /** |
||
130 | * @param mixed $debitedFunds |
||
131 | */ |
||
132 | public function setDebitedFunds($debitedFunds) |
||
136 | |||
137 | /** |
||
138 | * @return mixed |
||
139 | */ |
||
140 | public function getFees() |
||
144 | |||
145 | /** |
||
146 | * @param mixed $fees |
||
147 | */ |
||
148 | public function setFees($fees) |
||
152 | |||
153 | /** |
||
154 | * @return mixed |
||
155 | */ |
||
156 | public function getFeesCurrency() |
||
160 | |||
161 | /** |
||
162 | * @param mixed $feesCurrency |
||
163 | */ |
||
164 | public function setFeesCurrency($feesCurrency) |
||
168 | |||
169 | /** |
||
170 | * @return mixed |
||
171 | */ |
||
172 | public function getSecureModeReturnUrl() |
||
176 | |||
177 | /** |
||
178 | * @param mixed $secureModeReturnUrl |
||
179 | */ |
||
180 | public function setSecureModeReturnUrl($secureModeReturnUrl) |
||
184 | |||
185 | /** |
||
186 | * @return mixed |
||
187 | */ |
||
188 | public function getCardId() |
||
192 | |||
193 | /** |
||
194 | * @param mixed $cardId |
||
195 | */ |
||
196 | public function setCardId($cardId) |
||
200 | |||
201 | /** |
||
202 | * @return mixed |
||
203 | */ |
||
204 | public function getSecureMode() |
||
208 | |||
209 | /** |
||
210 | * @param mixed $secureMode |
||
211 | */ |
||
212 | public function setSecureMode($secureMode) |
||
216 | |||
217 | /** |
||
218 | * @return mixed |
||
219 | */ |
||
220 | public function getStatementDescriptor() |
||
224 | |||
225 | /** |
||
226 | * @param mixed $statementDescriptor |
||
227 | */ |
||
228 | public function setStatementDescriptor($statementDescriptor) |
||
232 | |||
233 | /** |
||
234 | * @return mixed |
||
235 | */ |
||
236 | public function getAmount() |
||
240 | |||
241 | /** |
||
242 | * @param mixed $amount |
||
243 | */ |
||
244 | public function setAmount($amount) |
||
248 | |||
249 | /** |
||
250 | * @return mixed |
||
251 | */ |
||
252 | public function getCurrency() |
||
256 | |||
257 | /** |
||
258 | * @param mixed $currency |
||
259 | */ |
||
260 | public function setCurrency($currency) |
||
264 | |||
265 | /** |
||
266 | * @return mixed |
||
267 | */ |
||
268 | public function getCardType() |
||
272 | |||
273 | /** |
||
274 | * @param mixed $cardType |
||
275 | */ |
||
276 | public function setCardType($cardType) |
||
280 | |||
281 | /** |
||
282 | * @return mixed |
||
283 | */ |
||
284 | public function getStatus() |
||
288 | |||
289 | /** |
||
290 | * @param mixed $status |
||
291 | */ |
||
292 | public function setStatus($status) |
||
296 | |||
297 | /** |
||
298 | * @return mixed |
||
299 | */ |
||
300 | public function getSecureModeNeeded() |
||
304 | |||
305 | /** |
||
306 | * @param mixed $secureModeNeeded |
||
307 | */ |
||
308 | public function setSecureModeNeeded($secureModeNeeded) |
||
312 | |||
313 | /** |
||
314 | * @return mixed |
||
315 | */ |
||
316 | public function getSecureModeRedirectUrl() |
||
320 | |||
321 | /** |
||
322 | * @param mixed $secureModeRedirectUrl |
||
323 | */ |
||
324 | public function setSecureModeRedirectUrl($secureModeRedirectUrl) |
||
328 | |||
329 | /** |
||
330 | * @return mixed |
||
331 | */ |
||
332 | public function getResourceId() |
||
336 | |||
337 | /** |
||
338 | * @param mixed $resourceId |
||
339 | */ |
||
340 | public function setResourceId($resourceId) |
||
344 | |||
345 | /** |
||
346 | * @return mixed |
||
347 | */ |
||
348 | public function getResultCode() |
||
352 | |||
353 | /** |
||
354 | * @param mixed $resultCode |
||
355 | */ |
||
356 | public function setResultCode($resultCode) |
||
360 | |||
361 | /** |
||
362 | * @return mixed |
||
363 | */ |
||
364 | public function getResultMessage() |
||
368 | |||
369 | /** |
||
370 | * @param mixed $resultMessage |
||
371 | */ |
||
372 | public function setResultMessage($resultMessage) |
||
376 | |||
377 | |||
378 | |||
379 | } |
||
380 |