Complex classes like Payone_Api_Request_CreateAccess 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 Payone_Api_Request_CreateAccess, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 33 | class Payone_Api_Request_CreateAccess extends Payone_Api_Request_Abstract |
||
| 34 | { |
||
| 35 | protected $request = Payone_Api_Enum_RequestType::CREATEACCESS; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Sub account ID |
||
| 39 | * |
||
| 40 | * @var int |
||
| 41 | */ |
||
| 42 | protected $aid = NULL; |
||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | protected $clearingtype = NULL; |
||
| 47 | /** |
||
| 48 | * Merchant reference number for the payment process. (Permitted symbols: 0-9, a-z, A-Z, .,-,_,/) |
||
| 49 | * |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | protected $reference = NULL; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Offer ID |
||
| 56 | * |
||
| 57 | * @var int |
||
| 58 | */ |
||
| 59 | protected $productid = NULL; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Individual Parameter |
||
| 63 | * |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | protected $param = NULL; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Username of customer |
||
| 70 | * |
||
| 71 | * @var string |
||
| 72 | */ |
||
| 73 | protected $accessname = NULL; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Pass of customer |
||
| 77 | * |
||
| 78 | * @var string |
||
| 79 | */ |
||
| 80 | protected $accesscode = NULL; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Startdate of access as unixtimestamp |
||
| 84 | * |
||
| 85 | * @var int |
||
| 86 | */ |
||
| 87 | protected $access_starttime = NULL; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Expiredate of first term or timestamp of renewal as unixtimestamp |
||
| 91 | * |
||
| 92 | * @var int |
||
| 93 | */ |
||
| 94 | protected $access_expiretime = NULL; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Canelationdate as unixtimestamp |
||
| 98 | * |
||
| 99 | * @var int |
||
| 100 | */ |
||
| 101 | protected $access_canceltime = NULL; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Entire price of first term, must be equal to sum of amount * price. Must be in smallest currency unit |
||
| 105 | * |
||
| 106 | * @var int |
||
| 107 | */ |
||
| 108 | protected $amount_trail = NULL; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Time unit of first term |
||
| 112 | * |
||
| 113 | * @var string |
||
| 114 | */ |
||
| 115 | protected $period_unit_trail = NULL; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Lenght of first term |
||
| 119 | * |
||
| 120 | * @var int |
||
| 121 | */ |
||
| 122 | protected $period_length_trail = NULL; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Entire price of all products in one renewal term. Must be in smallest currency unit |
||
| 126 | * |
||
| 127 | * @var int |
||
| 128 | */ |
||
| 129 | protected $amount_recurring = NULL; |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Time unit of renewal term |
||
| 133 | * |
||
| 134 | * @var string |
||
| 135 | */ |
||
| 136 | protected $period_unit_recurring = NULL; |
||
| 137 | |||
| 138 | /** |
||
| 139 | * Length of renewal term |
||
| 140 | * |
||
| 141 | * @var int |
||
| 142 | */ |
||
| 143 | protected $period_length_recurring = NULL; |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Currency (ISO-4217) |
||
| 147 | * |
||
| 148 | * @var string |
||
| 149 | */ |
||
| 150 | protected $currency = NULL; |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @var Payone_Api_Request_Parameter_CreateAccess_Billing |
||
| 154 | */ |
||
| 155 | protected $billing = null; |
||
| 156 | /** |
||
| 157 | * @var Payone_Api_Request_Parameter_CreateAccess_Invoicing_Transaction |
||
| 158 | */ |
||
| 159 | protected $invoicing = null; |
||
| 160 | /** |
||
| 161 | * @var Payone_Api_Request_Parameter_CreateAccess_PersonalData |
||
| 162 | */ |
||
| 163 | protected $personaldata = null; |
||
| 164 | /** |
||
| 165 | * @var Payone_Api_Request_Parameter_CreateAccess_PaymentMethod_Abstract |
||
| 166 | */ |
||
| 167 | protected $payment = null; |
||
| 168 | /** |
||
| 169 | * @var Payone_Api_Request_Parameter_CreateAccess_3dsecure |
||
| 170 | */ |
||
| 171 | protected $_3dsecure = null; |
||
| 172 | |||
| 173 | |||
| 174 | /** |
||
| 175 | * @param int $access_canceltime |
||
| 176 | */ |
||
| 177 | public function setAccessCanceltime($access_canceltime) |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @return int |
||
| 184 | */ |
||
| 185 | public function getAccessCanceltime() |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @param int $access_expiretime |
||
| 192 | */ |
||
| 193 | public function setAccessExpiretime($access_expiretime) |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @return int |
||
| 200 | */ |
||
| 201 | public function getAccessExpiretime() |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @param int $access_starttime |
||
| 208 | */ |
||
| 209 | public function setAccessStarttime($access_starttime) |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @return int |
||
| 216 | */ |
||
| 217 | public function getAccessStarttime() |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @param string $accesscode |
||
| 224 | */ |
||
| 225 | public function setAccesscode($accesscode) |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @return string |
||
| 232 | */ |
||
| 233 | public function getAccesscode() |
||
| 237 | |||
| 238 | /** |
||
| 239 | * @param string $accessname |
||
| 240 | */ |
||
| 241 | public function setAccessname($accessname) |
||
| 245 | |||
| 246 | /** |
||
| 247 | * @return string |
||
| 248 | */ |
||
| 249 | public function getAccessname() |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @param int $aid |
||
| 256 | */ |
||
| 257 | public function setAid($aid) |
||
| 261 | |||
| 262 | /** |
||
| 263 | * @return int |
||
| 264 | */ |
||
| 265 | public function getAid() |
||
| 269 | |||
| 270 | /** |
||
| 271 | * @param int $amount_recurring |
||
| 272 | */ |
||
| 273 | public function setAmountRecurring($amount_recurring) |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @return int |
||
| 280 | */ |
||
| 281 | public function getAmountRecurring() |
||
| 285 | |||
| 286 | /** |
||
| 287 | * @param int $amount_trail |
||
| 288 | */ |
||
| 289 | public function setAmountTrail($amount_trail) |
||
| 293 | |||
| 294 | /** |
||
| 295 | * @return int |
||
| 296 | */ |
||
| 297 | public function getAmountTrail() |
||
| 301 | |||
| 302 | /** |
||
| 303 | * @param string $clearingtype |
||
| 304 | */ |
||
| 305 | public function setClearingtype($clearingtype) |
||
| 309 | |||
| 310 | /** |
||
| 311 | * @return string |
||
| 312 | */ |
||
| 313 | public function getClearingtype() |
||
| 317 | |||
| 318 | /** |
||
| 319 | * @param string $param |
||
| 320 | */ |
||
| 321 | public function setParam($param) |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @return string |
||
| 328 | */ |
||
| 329 | public function getParam() |
||
| 333 | |||
| 334 | /** |
||
| 335 | * @param int $period_length_recurring |
||
| 336 | */ |
||
| 337 | public function setPeriodLengthRecurring($period_length_recurring) |
||
| 341 | |||
| 342 | /** |
||
| 343 | * @return int |
||
| 344 | */ |
||
| 345 | public function getPeriodLengthRecurring() |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @param int $period_length_trail |
||
| 352 | */ |
||
| 353 | public function setPeriodLengthTrail($period_length_trail) |
||
| 357 | |||
| 358 | /** |
||
| 359 | * @return int |
||
| 360 | */ |
||
| 361 | public function getPeriodLengthTrail() |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @param string $period_unit_recurring |
||
| 368 | */ |
||
| 369 | public function setPeriodUnitRecurring($period_unit_recurring) |
||
| 373 | |||
| 374 | /** |
||
| 375 | * @return string |
||
| 376 | */ |
||
| 377 | public function getPeriodUnitRecurring() |
||
| 381 | |||
| 382 | /** |
||
| 383 | * @param string $period_unit_trail |
||
| 384 | */ |
||
| 385 | public function setPeriodUnitTrail($period_unit_trail) |
||
| 389 | |||
| 390 | /** |
||
| 391 | * @return string |
||
| 392 | */ |
||
| 393 | public function getPeriodUnitTrail() |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @param int $productid |
||
| 400 | */ |
||
| 401 | public function setProductid($productid) |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @return int |
||
| 408 | */ |
||
| 409 | public function getProductid() |
||
| 413 | |||
| 414 | /** |
||
| 415 | * @param string $reference |
||
| 416 | */ |
||
| 417 | public function setReference($reference) |
||
| 421 | |||
| 422 | /** |
||
| 423 | * @return string |
||
| 424 | */ |
||
| 425 | public function getReference() |
||
| 429 | |||
| 430 | /** |
||
| 431 | * @param \Payone_Api_Request_Parameter_CreateAccess_Billing $billing |
||
| 432 | */ |
||
| 433 | public function setBilling(Payone_Api_Request_Parameter_CreateAccess_Billing $billing) |
||
| 437 | |||
| 438 | /** |
||
| 439 | * @return \Payone_Api_Request_Parameter_CreateAccess_Billing |
||
| 440 | */ |
||
| 441 | public function getBilling() |
||
| 445 | |||
| 446 | /** |
||
| 447 | * @param \Payone_Api_Request_Parameter_CreateAccess_Invoicing_Transaction $invoicing |
||
| 448 | */ |
||
| 449 | public function setInvoicing(Payone_Api_Request_Parameter_CreateAccess_Invoicing_Transaction $invoicing) |
||
| 453 | |||
| 454 | /** |
||
| 455 | * @return \Payone_Api_Request_Parameter_CreateAccess_Invoicing_Transaction |
||
| 456 | */ |
||
| 457 | public function getInvoicing() |
||
| 461 | |||
| 462 | /** |
||
| 463 | * @param \Payone_Api_Request_Parameter_CreateAccess_PaymentMethod_Abstract $payment |
||
| 464 | */ |
||
| 465 | public function setPayment(Payone_Api_Request_Parameter_CreateAccess_PaymentMethod_Abstract $payment) |
||
| 469 | |||
| 470 | /** |
||
| 471 | * @return \Payone_Api_Request_Parameter_CreateAccess_PaymentMethod_Abstract |
||
| 472 | */ |
||
| 473 | public function getPayment() |
||
| 477 | |||
| 478 | /** |
||
| 479 | * @param \Payone_Api_Request_Parameter_CreateAccess_PersonalData $personaldata |
||
| 480 | */ |
||
| 481 | public function setPersonaldata(Payone_Api_Request_Parameter_CreateAccess_PersonalData $personaldata) |
||
| 485 | |||
| 486 | /** |
||
| 487 | * @return \Payone_Api_Request_Parameter_CreateAccess_PersonalData |
||
| 488 | */ |
||
| 489 | public function getPersonaldata() |
||
| 493 | |||
| 494 | /** |
||
| 495 | * @param \Payone_Api_Request_Parameter_CreateAccess_3dsecure $secure |
||
| 496 | */ |
||
| 497 | public function set3dsecure(Payone_Api_Request_Parameter_CreateAccess_3dsecure $secure) |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @return \Payone_Api_Request_Parameter_CreateAccess_3dsecure |
||
| 504 | */ |
||
| 505 | public function get3dsecure() |
||
| 509 | |||
| 510 | /** |
||
| 511 | * @param string $currency |
||
| 512 | */ |
||
| 513 | public function setCurrency($currency) |
||
| 517 | |||
| 518 | /** |
||
| 519 | * @return string |
||
| 520 | */ |
||
| 521 | public function getCurrency() |
||
| 525 | |||
| 526 | } |
||
| 527 |