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 |
||
87 | public function execute() |
||
88 | { |
||
89 | $request = $this->context->getRequest(); |
||
90 | $result = $this->rawResultFactory->create(); |
||
91 | |||
92 | $validationResult = $this->validator->validate(['request' => $request]); |
||
93 | |||
94 | $validation = $validationResult->getFailsDescription(); |
||
95 | |||
96 | if (!$validationResult->isValid()) { |
||
97 | $result->setStatusHeader($validation['status'], '1.1', $validation['message']); |
||
98 | |||
99 | return $result; |
||
100 | } |
||
101 | |||
102 | $order = $validation['order']; |
||
103 | $payment = $order->getPayment(); |
||
104 | $params = $request->getParams(); |
||
105 | |||
106 | $billStatus = (string)$params['status']; |
||
107 | |||
108 | if ('2' === $billStatus) { |
||
109 | if ($params['amount'] === $params['actual_amount']) { |
||
110 | $totalDue = $order->getTotalDue(); |
||
111 | |||
112 | $payment->authorize(false, $totalDue); |
||
113 | $payment->registerCaptureNotification($totalDue); |
||
114 | |||
115 | $order->addStatusToHistory( |
||
116 | $order::STATE_PROCESSING, |
||
117 | __('B2BinPay payment complete!') |
||
118 | ); |
||
119 | } else { |
||
120 | $actualAmount = $this->amountFactory->create( |
||
121 | $params['actual_amount'], |
||
122 | $params['currency']['iso'], |
||
123 | $params['pow'] |
||
124 | )->getValue(); |
||
125 | |||
126 | $order->addStatusToHistory( |
||
127 | $order::STATE_PAYMENT_REVIEW, |
||
128 | __('B2BinPay received payment: ' . $actualAmount . $params['currency']['alpha']) |
||
129 | ); |
||
130 | } |
||
131 | } |
||
132 | |||
133 | $stateList = $this->getStateDesc(); |
||
134 | |||
135 | if (!empty($stateList[$billStatus])) { |
||
136 | $order->addStatusToHistory( |
||
137 | $stateList[$billStatus]['state'], |
||
138 | $stateList[$billStatus]['message'] |
||
139 | ); |
||
140 | } |
||
141 | |||
142 | $order->save(); |
||
143 | |||
144 | $result->setStatusHeader('200', '1.1', 'OK'); |
||
145 | $result->setContents('OK'); |
||
146 | |||
147 | return $result; |
||
148 | } |
||
175 |
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