| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 52 | public function get_document() { |
||
| 53 | $document = parent::get_document(); |
||
| 54 | |||
| 55 | // Issuer. |
||
| 56 | $issuer = $this->issuer; |
||
| 57 | |||
| 58 | $element = self::add_element( $document, $document->documentElement, 'Issuer' ); |
||
| 59 | |||
| 60 | self::add_element( |
||
| 61 | $document, |
||
| 62 | $element, |
||
| 63 | 'issuerID', |
||
| 64 | $issuer->get_id() |
||
| 65 | ); |
||
| 66 | |||
| 67 | // Merchant. |
||
| 68 | $merchant = $this->get_merchant(); |
||
| 69 | |||
| 70 | $element = self::add_element( $document, $document->documentElement, 'Merchant' ); |
||
| 71 | |||
| 72 | self::add_elements( |
||
| 73 | $document, |
||
| 74 | $element, |
||
| 75 | array( |
||
| 76 | 'merchantID' => $merchant->get_id(), |
||
| 77 | 'subID' => $merchant->get_sub_id(), |
||
| 78 | 'merchantReturnURL' => $merchant->get_return_url(), |
||
| 79 | ) |
||
| 80 | ); |
||
| 81 | |||
| 82 | // Transaction. |
||
| 83 | $transaction = $this->transaction; |
||
| 84 | |||
| 85 | $element = self::add_element( $document, $document->documentElement, 'Transaction' ); |
||
| 86 | |||
| 87 | self::add_elements( |
||
| 88 | $document, |
||
| 89 | $element, |
||
| 90 | array( |
||
| 91 | 'purchaseID' => $transaction->get_purchase_id(), |
||
| 92 | 'amount' => IDeal::format_amount( $transaction->get_amount() ), |
||
|
|
|||
| 93 | 'currency' => $transaction->get_currency(), |
||
| 94 | 'expirationPeriod' => $transaction->get_expiration_period(), |
||
| 95 | 'language' => $transaction->get_language(), |
||
| 96 | 'description' => $transaction->get_description(), |
||
| 97 | 'entranceCode' => $transaction->get_entrance_code(), |
||
| 98 | ) |
||
| 99 | ); |
||
| 100 | |||
| 101 | // Return. |
||
| 102 | return $document; |
||
| 103 | } |
||
| 105 |