Conditions | 15 |
Paths | 16384 |
Total Lines | 78 |
Code Lines | 46 |
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 |
||
145 | public function startPaymentProcess() |
||
146 | { |
||
147 | if (!$this->TxnId) { |
||
148 | $this->TxnId = uniqid("ID"); |
||
149 | } |
||
150 | $request = new PxPayRequest(); |
||
151 | |||
152 | #Set PxPay properties |
||
153 | if ($this->MerchantReference) { |
||
154 | $request->setMerchantReference($this->MerchantReference); |
||
155 | } else { |
||
156 | user_error("error in DpsPxPayComs::startPaymentProcess, MerchantReference not set. ", E_USER_WARNING); |
||
157 | } |
||
158 | if ($this->AmountInput) { |
||
159 | $request->setAmountInput($this->AmountInput); |
||
160 | } else { |
||
161 | user_error("error in DpsPxPayComs::startPaymentProcess, AmountInput not set. ", E_USER_WARNING); |
||
162 | } |
||
163 | if ($this->TxnData1) { |
||
164 | $request->setTxnData1($this->TxnData1); |
||
165 | } |
||
166 | if ($this->TxnData2) { |
||
167 | $request->setTxnData2($this->TxnData2); |
||
168 | } |
||
169 | if ($this->TxnData3) { |
||
170 | $request->setTxnData3($this->TxnData3); |
||
171 | } |
||
172 | if ($this->TxnType) { |
||
173 | $request->setTxnType($this->TxnType); |
||
174 | } else { |
||
175 | user_error("error in DpsPxPayComs::startPaymentProcess, TxnType not set. ", E_USER_WARNING); |
||
176 | } |
||
177 | if ($this->CurrencyInput) { |
||
178 | $request->setCurrencyInput($this->CurrencyInput); |
||
179 | } else { |
||
180 | user_error("error in DpsPxPayComs::startPaymentProcess, CurrencyInput not set. ", E_USER_WARNING); |
||
181 | } |
||
182 | if ($this->EmailAddress) { |
||
183 | $request->setEmailAddress($this->EmailAddress); |
||
184 | } |
||
185 | if ($this->UrlFail) { |
||
186 | $request->setUrlFail($this->UrlFail); |
||
187 | } else { |
||
188 | user_error("error in DpsPxPayComs::startPaymentProcess, UrlFail not set. ", E_USER_WARNING); |
||
189 | } |
||
190 | if ($this->UrlSuccess) { |
||
191 | $request->setUrlSuccess($this->UrlSuccess); |
||
192 | } else { |
||
193 | user_error("error in DpsPxPayComs::startPaymentProcess, UrlSuccess not set. ", E_USER_WARNING); |
||
194 | } |
||
195 | if ($this->TxnId) { |
||
196 | $request->setTxnId($this->TxnId); |
||
197 | } |
||
198 | if ($this->EnableAddBillCard) { |
||
199 | $request->setEnableAddBillCard($this->EnableAddBillCard); |
||
200 | } |
||
201 | if ($this->BillingId) { |
||
202 | $request->setBillingId($this->BillingId); |
||
203 | } |
||
204 | |||
205 | /* TODO: |
||
206 | $request->setEnableAddBillCard($EnableAddBillCard); |
||
207 | $request->setBillingId($BillingId); |
||
208 | $request->setOpt($Opt); |
||
209 | */ |
||
210 | |||
211 | #Call makeRequest function to obtain input XML |
||
212 | $request_string = $this->PxPayObject->makeRequest($request); |
||
213 | |||
214 | #Obtain output XML |
||
215 | $this->response = new MifMessage($request_string); |
||
216 | #Parse output XML |
||
217 | $url = $this->response->get_element_text("URI"); |
||
218 | //$valid = $this->response->get_attribute("valid"); |
||
219 | |||
220 | #Redirect to payment page |
||
221 | return $url; |
||
222 | } |
||
223 | |||
276 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.