| Conditions | 7 |
| Paths | 57 |
| Total Lines | 57 |
| Code Lines | 36 |
| 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 |
||
| 43 | public function payment($invoice, Request $request) |
||
| 44 | { |
||
| 45 | |||
| 46 | //Input items of form |
||
| 47 | $input = Input::all(); |
||
| 48 | |||
| 49 | $success = true; |
||
| 50 | $error = 'Payment Failed'; |
||
| 51 | $rzp_key = ApiKey::where('id', 1)->value('rzp_key'); |
||
| 52 | $rzp_secret = ApiKey::where('id', 1)->value('rzp_secret'); |
||
| 53 | |||
| 54 | $api = new Api($rzp_key, $rzp_secret); |
||
| 55 | $payment = $api->payment->fetch($input['razorpay_payment_id']); |
||
| 56 | |||
| 57 | if (count($input) && !empty($input['razorpay_payment_id'])) { //Verify Razorpay Payment Id and Signature |
||
| 58 | |||
| 59 | //Fetch payment information by razorpay_payment_id |
||
| 60 | try { |
||
| 61 | $response = $api->payment->fetch($input['razorpay_payment_id']); |
||
| 62 | } catch (SignatureVerificationError $e) { |
||
| 63 | $success = false; |
||
| 64 | $error = 'Razorpay Error : '.$e->getMessage(); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | $state = $this->getState(\Auth::user()->state); |
||
|
|
|||
| 68 | $invoice = Invoice::where('id', $invoice)->first(); |
||
| 69 | |||
| 70 | if ($success === true) { |
||
| 71 | try { |
||
| 72 | //Change order Status as Success if payment is Successful |
||
| 73 | $control = new \App\Http\Controllers\Order\RenewController(); |
||
| 74 | |||
| 75 | if ($control->checkRenew() === false) { |
||
| 76 | $checkout_controller = new \App\Http\Controllers\Front\CheckoutController(); |
||
| 77 | $checkout_controller->checkoutAction($invoice); |
||
| 78 | |||
| 79 | $view = $this->getViewMessageAfterPayment($invoice); |
||
| 80 | $status = $view['status']; |
||
| 81 | $message = $view['message']; |
||
| 82 | |||
| 83 | \Session::forget('items'); |
||
| 84 | } else { |
||
| 85 | $control->successRenew($invoice); |
||
| 86 | $payment = new \App\Http\Controllers\Order\InvoiceController(); |
||
| 87 | $payment->postRazorpayPayment($invoice->id, $invoice->grand_total); |
||
| 88 | |||
| 89 | $view = $this->getViewMessageAfterRenew($invoice); |
||
| 90 | $status = $view['status']; |
||
| 91 | $message = $view['message']; |
||
| 92 | |||
| 93 | |||
| 94 | } |
||
| 95 | |||
| 96 | return redirect()->back()->with($status, $message); |
||
| 97 | } catch (\Exception $ex) { |
||
| 98 | dd($ex); |
||
| 99 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); |
||
| 100 | } |
||
| 149 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.