| Conditions | 2 |
| Paths | 2 |
| Total Lines | 81 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 58 | public function get_document() { |
||
| 59 | $document = parent::get_document(); |
||
| 60 | |||
| 61 | // Merchant. |
||
| 62 | $merchant = XML_Util::add_element( $document, $document->documentElement, 'merchant' ); |
||
| 63 | |||
| 64 | XML_Util::add_elements( |
||
| 65 | $document, |
||
| 66 | $merchant, |
||
| 67 | array( |
||
| 68 | 'account' => $this->merchant->account, |
||
| 69 | 'site_id' => $this->merchant->site_id, |
||
| 70 | 'site_secure_code' => $this->merchant->site_secure_code, |
||
| 71 | 'notification_url' => $this->merchant->notification_url, |
||
| 72 | 'redirect_url' => $this->merchant->redirect_url, |
||
| 73 | 'cancel_url' => $this->merchant->cancel_url, |
||
| 74 | 'close_window' => $this->merchant->close_window, |
||
| 75 | ) |
||
| 76 | ); |
||
| 77 | |||
| 78 | // Customer. |
||
| 79 | $customer = XML_Util::add_element( $document, $document->documentElement, 'customer' ); |
||
| 80 | |||
| 81 | XML_Util::add_elements( |
||
| 82 | $document, |
||
| 83 | $customer, |
||
| 84 | array( |
||
| 85 | 'locale' => $this->customer->locale, |
||
| 86 | 'ipaddress' => $this->customer->ip_address, |
||
| 87 | 'forwardedip' => $this->customer->forwarded_ip, |
||
| 88 | 'firstname' => $this->customer->first_name, |
||
| 89 | 'lastname' => $this->customer->last_name, |
||
| 90 | 'address1' => $this->customer->address_1, |
||
| 91 | 'address2' => $this->customer->address_2, |
||
| 92 | 'housenumber' => $this->customer->house_number, |
||
| 93 | 'zipcode' => $this->customer->zip_code, |
||
| 94 | 'city' => $this->customer->city, |
||
| 95 | 'country' => $this->customer->country, |
||
| 96 | 'phone' => $this->customer->phone, |
||
| 97 | 'email' => $this->customer->email, |
||
| 98 | ) |
||
| 99 | ); |
||
| 100 | |||
| 101 | // Transaction. |
||
| 102 | $transaction = XML_Util::add_element( $document, $document->documentElement, 'transaction' ); |
||
| 103 | |||
| 104 | XML_Util::add_elements( |
||
| 105 | $document, |
||
| 106 | $transaction, |
||
| 107 | array( |
||
| 108 | 'id' => $this->transaction->id, |
||
| 109 | 'currency' => $this->transaction->currency, |
||
| 110 | 'amount' => $this->transaction->amount, |
||
| 111 | 'description' => $this->transaction->description, |
||
| 112 | 'var1' => $this->transaction->var1, |
||
| 113 | 'var2' => $this->transaction->var2, |
||
| 114 | 'var3' => $this->transaction->var3, |
||
| 115 | 'items' => $this->transaction->items, |
||
| 116 | 'manual' => $this->transaction->manual, |
||
| 117 | 'gateway' => $this->transaction->gateway, |
||
| 118 | 'daysactive' => $this->transaction->days_active, |
||
| 119 | ) |
||
| 120 | ); |
||
| 121 | |||
| 122 | // Gateway info. |
||
| 123 | if ( $this->gateway_info ) { |
||
| 124 | $gateway_info = XML_Util::add_element( $document, $document->documentElement, 'gatewayinfo' ); |
||
| 125 | |||
| 126 | XML_Util::add_elements( |
||
| 127 | $document, |
||
| 128 | $gateway_info, |
||
| 129 | array( |
||
| 130 | 'issuerid' => $this->gateway_info->issuer_id, |
||
| 131 | ) |
||
| 132 | ); |
||
| 133 | } |
||
| 134 | |||
| 135 | // Signature. |
||
| 136 | XML_Util::add_element( $document, $document->documentElement, 'signature', $this->signature ); |
||
|
|
|||
| 137 | |||
| 138 | return $document; |
||
| 139 | } |
||
| 141 |