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 |
||
10 | class Getnet |
||
11 | { |
||
12 | /** @var */ |
||
13 | private $client_id; |
||
14 | |||
15 | /** @var */ |
||
16 | private $client_secret; |
||
17 | |||
18 | /** @var */ |
||
19 | private $environment; |
||
20 | |||
21 | /** @var */ |
||
22 | private $authorizationToken; |
||
23 | |||
24 | /** @var */ |
||
25 | private $keySession; |
||
26 | |||
27 | /** |
||
28 | * Getnet constructor. |
||
29 | * @param $client_id |
||
30 | * @param $client_secret |
||
31 | * @param Environment|null $environment |
||
32 | * @param null $keySession |
||
33 | * @throws \Exception |
||
34 | */ |
||
35 | public function __construct( |
||
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | public function getClientId() |
||
62 | |||
63 | /** |
||
64 | * @param $client_id |
||
65 | * @return $this |
||
66 | */ |
||
67 | public function setClientId($client_id) |
||
73 | |||
74 | /** |
||
75 | * @return string |
||
76 | */ |
||
77 | public function getClientSecret() |
||
81 | |||
82 | /** |
||
83 | * @param $client_secret |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function setClientSecret($client_secret) |
||
92 | |||
93 | /** |
||
94 | * @return Environment |
||
95 | */ |
||
96 | public function getEnvironment() |
||
100 | |||
101 | /** |
||
102 | * @param Environment $environment |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function setEnvironment(Environment $environment) |
||
111 | |||
112 | /** |
||
113 | * @return string |
||
114 | */ |
||
115 | public function getAuthorizationToken() |
||
119 | |||
120 | /** |
||
121 | * @param $authorizationToken |
||
122 | * @return $this |
||
123 | */ |
||
124 | public function setAuthorizationToken($authorizationToken) |
||
130 | |||
131 | /** |
||
132 | * @return string |
||
133 | */ |
||
134 | public function getKeySession() |
||
138 | |||
139 | /** |
||
140 | * @param $keySession |
||
141 | */ |
||
142 | public function setKeySession($keySession) |
||
146 | |||
147 | /** |
||
148 | * @param Transaction $transaction |
||
149 | * @return AuthorizeResponse|BaseResponse |
||
150 | */ |
||
151 | public function authorize(Transaction $transaction) |
||
175 | |||
176 | /** |
||
177 | * @param $payment_id |
||
178 | * @return AuthorizeResponse|BaseResponse |
||
179 | */ |
||
180 | public function authorizeConfirm($payment_id) |
||
197 | |||
198 | /** |
||
199 | * @param $payment_id |
||
200 | * @param $payer_authentication_response |
||
201 | * @return AuthorizeResponse|BaseResponse |
||
202 | */ |
||
203 | View Code Duplication | public function authorizeConfirmDebit($payment_id, $payer_authentication_response) |
|
221 | |||
222 | /** |
||
223 | * @param $payment_id |
||
224 | * @param $amount_val |
||
225 | * @return AuthorizeResponse|BaseResponse |
||
226 | */ |
||
227 | View Code Duplication | public function authorizeCancel($payment_id, $amount_val) |
|
246 | |||
247 | /** |
||
248 | * @param Transaction $transaction |
||
249 | * @return BaseResponse|BoletoResponse |
||
250 | */ |
||
251 | public function boleto(Transaction $transaction) |
||
270 | |||
271 | /** |
||
272 | * @param Card $card |
||
273 | * @return BaseResponse|CardVerificationResponse |
||
274 | */ |
||
275 | public function verifyCard(Card $card) |
||
292 | } |
||
293 |