| Conditions | 18 |
| Paths | 1329 |
| Total Lines | 107 |
| Code Lines | 84 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 115 | public function execute() |
||
| 116 | { |
||
| 117 | $currenctCart = $this->_getCheckout()->getQuote()->getId(); |
||
| 118 | $buyNowId = $this->_getCheckout()->getQuote()->getBuyNowId(); |
||
| 119 | $customerId = $this->_getCheckout()->getQuote()->getCustomerId(); |
||
| 120 | try { |
||
| 121 | $this->paymentRateLimiter->limit(); |
||
| 122 | if (!$this->_validateMinimumAmount()) { |
||
| 123 | return; |
||
| 124 | } |
||
| 125 | |||
| 126 | if (!$this->agreementsValidator->isValid(array_keys($this->getRequest()->getPost('agreement', [])))) { |
||
| 127 | $this->messageManager->addErrorMessage( |
||
| 128 | __('Please agree to all Terms and Conditions before placing the order.') |
||
| 129 | ); |
||
| 130 | $this->_redirect('*/*/billing'); |
||
| 131 | return; |
||
| 132 | } |
||
| 133 | |||
| 134 | $payment = $this->getRequest()->getPost('payment'); |
||
| 135 | $paymentInstance = $this->_getCheckout()->getQuote()->getPayment(); |
||
| 136 | if (isset($payment['cc_number'])) { |
||
| 137 | $paymentInstance->setCcNumber($payment['cc_number']); |
||
| 138 | } |
||
| 139 | if (isset($payment['cc_cid'])) { |
||
| 140 | $paymentInstance->setCcCid($payment['cc_cid']); |
||
| 141 | } |
||
| 142 | $this->_getCheckout()->createOrders(); |
||
| 143 | $this->_getState()->setCompleteStep(State::STEP_OVERVIEW); |
||
| 144 | |||
| 145 | if ($this->session->getAddressErrors()) { |
||
| 146 | $this->_getState()->setActiveStep(State::STEP_RESULTS); |
||
| 147 | $this->_redirect('*/*/results'); |
||
| 148 | } else { |
||
| 149 | $this->_getState()->setActiveStep(State::STEP_SUCCESS); |
||
| 150 | $this->_getCheckout()->getCheckoutSession()->clearQuote(); |
||
| 151 | $this->_getCheckout()->getCheckoutSession()->setDisplaySuccess(true); |
||
| 152 | /* get buy now feture */ |
||
| 153 | if (($customerId) && ($buyNowId)) { |
||
| 154 | $customerRepoData = $this->customerRepository->getById($customerId); |
||
| 155 | /* Update Currenct Cart */ |
||
| 156 | if ($currenctCart) { |
||
| 157 | $UpadateCurrenctCart = $this->quoteFactory->create(); |
||
| 158 | $UpadateCurrenctCart->load($currenctCart); |
||
| 159 | if ($UpadateCurrenctCart->hasData()) { |
||
| 160 | $UpadateCurrenctCart->setBuyNowId(0); |
||
| 161 | $UpadateCurrenctCart->setIsActive(0); |
||
| 162 | $UpadateCurrenctCart->save(); |
||
| 163 | } |
||
| 164 | } |
||
| 165 | /* Restore old Cart */ |
||
| 166 | $quoteDataReplace = $this->quoteFactory->create(); |
||
| 167 | $quoteDataReplace->load($buyNowId); |
||
| 168 | if ($quoteDataReplace->hasData()) { |
||
| 169 | $quoteDataReplace->assignCustomer($customerRepoData); |
||
| 170 | $quoteDataReplace->setBuyNowId(0); |
||
| 171 | $quoteDataReplace->setIsActive(1); |
||
| 172 | $quoteDataReplace->save(); |
||
| 173 | } |
||
| 174 | } |
||
| 175 | $this->_redirect('*/*/success'); |
||
| 176 | } |
||
| 177 | } catch (PaymentProcessingRateLimitExceededException $ex) { |
||
| 178 | $this->messageManager->addErrorMessage($ex->getMessage()); |
||
| 179 | $this->_redirect('*/*/overview'); |
||
| 180 | } catch (PaymentException $e) { |
||
| 181 | $message = $e->getMessage(); |
||
| 182 | if (!empty($message)) { |
||
| 183 | $this->messageManager->addErrorMessage($message); |
||
| 184 | } |
||
| 185 | $this->_redirect('*/*/billing'); |
||
| 186 | } catch (\Magento\Checkout\Exception $e) { |
||
| 187 | $this->_objectManager->get( |
||
| 188 | \Magento\Checkout\Helper\Data::class |
||
| 189 | )->sendPaymentFailedEmail( |
||
| 190 | $this->_getCheckout()->getQuote(), |
||
| 191 | $e->getMessage(), |
||
| 192 | 'multi-shipping' |
||
| 193 | ); |
||
| 194 | $this->_getCheckout()->getCheckoutSession()->clearQuote(); |
||
| 195 | $this->messageManager->addErrorMessage($e->getMessage()); |
||
| 196 | $this->_redirect('*/cart'); |
||
| 197 | } catch (\Magento\Framework\Exception\LocalizedException $e) { |
||
| 198 | $this->_objectManager->get( |
||
| 199 | \Magento\Checkout\Helper\Data::class |
||
| 200 | )->sendPaymentFailedEmail( |
||
| 201 | $this->_getCheckout()->getQuote(), |
||
| 202 | $e->getMessage(), |
||
| 203 | 'multi-shipping' |
||
| 204 | ); |
||
| 205 | $this->messageManager->addErrorMessage($e->getMessage()); |
||
| 206 | $this->_redirect('*/*/billing'); |
||
| 207 | } catch (\Exception $e) { |
||
| 208 | $this->logger->critical($e); |
||
| 209 | try { |
||
| 210 | $this->_objectManager->get( |
||
| 211 | \Magento\Checkout\Helper\Data::class |
||
| 212 | )->sendPaymentFailedEmail( |
||
| 213 | $this->_getCheckout()->getQuote(), |
||
| 214 | $e->getMessage(), |
||
| 215 | 'multi-shipping' |
||
| 216 | ); |
||
| 217 | } catch (\Exception $e) { |
||
| 218 | $this->logger->error($e->getMessage()); |
||
| 219 | } |
||
| 220 | $this->messageManager->addErrorMessage(__('Order place error')); |
||
| 221 | $this->_redirect('*/*/billing'); |
||
| 222 | } |
||
| 225 |
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