Conditions | 5 |
Paths | 7 |
Total Lines | 61 |
Code Lines | 37 |
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 |
||
66 | public function execute() |
||
67 | { |
||
68 | $request = $this->context->getRequest(); |
||
69 | $result = $this->rawResultFactory->create(); |
||
70 | |||
71 | $validationResult = $this->validator->validate(['request' => $request]); |
||
72 | |||
73 | $validation = $validationResult->getFailsDescription(); |
||
74 | |||
75 | if (!$validationResult->isValid()) { |
||
76 | $result->setStatusHeader($validation['status'], '1.1', $validation['message']); |
||
77 | |||
78 | return $result; |
||
79 | } |
||
80 | |||
81 | $order = $validation['order']; |
||
82 | $payment = $order->getPayment(); |
||
83 | $params = $request->getParams(); |
||
84 | |||
85 | $billStatus = (string)$params['status']; |
||
86 | |||
87 | if ('2' === $billStatus) { |
||
88 | if ($params['amount'] === $params['actual_amount']) { |
||
89 | $totalDue = $order->getTotalDue(); |
||
90 | |||
91 | $payment->authorize(false, $totalDue); |
||
92 | $payment->registerCaptureNotification($totalDue); |
||
93 | |||
94 | $order->addStatusToHistory( |
||
95 | $order::STATE_PROCESSING, |
||
96 | __('B2BinPay payment complete!') |
||
97 | ); |
||
98 | } else { |
||
99 | $actualAmount = $this->amountFactory->create( |
||
100 | $params['actual_amount'], |
||
101 | $params['currency']['iso'], |
||
102 | $params['pow'] |
||
103 | )->getValue(); |
||
104 | |||
105 | $order->addStatusToHistory( |
||
106 | $order::STATE_PAYMENT_REVIEW, |
||
107 | __('B2BinPay received payment: ' . $actualAmount . $params['currency']['alpha']) |
||
108 | ); |
||
109 | } |
||
110 | } |
||
111 | |||
112 | $stateList = $this->getStateDesc(); |
||
113 | |||
114 | if (!empty($stateList[$billStatus])) { |
||
115 | $order->addStatusToHistory( |
||
116 | $stateList[$billStatus]['state'], |
||
117 | $stateList[$billStatus]['message'] |
||
118 | ); |
||
119 | } |
||
120 | |||
121 | $order->save(); |
||
122 | |||
123 | $result->setStatusHeader('200', '1.1', 'OK'); |
||
124 | $result->setContents('OK'); |
||
125 | |||
126 | return $result; |
||
127 | } |
||
154 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths