| Conditions | 9 |
| Paths | 44 |
| Total Lines | 57 |
| Code Lines | 35 |
| 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 |
||
| 95 | public function execute() |
||
| 96 | { |
||
| 97 | if ($this->isValidationRequired() && |
||
| 98 | !$this->agreementsValidator->isValid(array_keys($this->getRequest()->getPost('agreement', []))) |
||
| 99 | ) { |
||
| 100 | $e = new \Magento\Framework\Exception\LocalizedException( |
||
| 101 | __('Please agree to all the terms and conditions before placing the order.') |
||
| 102 | ); |
||
| 103 | $this->messageManager->addExceptionMessage($e, $e->getMessage()); |
||
| 104 | $this->_redirect('*/*/review'); |
||
| 105 | return; |
||
| 106 | } |
||
| 107 | |||
| 108 | try { |
||
| 109 | $oQuote = $this->checkoutSession->getQuote(); |
||
| 110 | |||
| 111 | if ($this->checkoutHelper->getQuoteComparisonString($oQuote) != $this->checkoutSession->getPayoneQuoteComparisonString()) { |
||
| 112 | // The basket was changed - abort current checkout |
||
| 113 | $this->messageManager->addErrorMessage('An error occured during the Checkout.'); |
||
| 114 | $this->_redirect('checkout/cart'); |
||
| 115 | return; |
||
| 116 | } |
||
| 117 | |||
| 118 | if (!empty($this->checkoutSession->getPayoneQuoteAddressHash()) && $this->checkoutHelper->getQuoteAddressHash($oQuote) != $this->checkoutSession->getPayoneQuoteAddressHash()) { |
||
| 119 | // Address has been changed which is not allowed to happen - reset it to the address given by the Express payment method |
||
| 120 | $aExpressAddressResponse = $this->checkoutSession->getPayoneExpressAddressResponse(); |
||
| 121 | |||
| 122 | $blUseBilling = true; |
||
| 123 | if (in_array($oQuote->getPayment()->getMethod(), [PayoneConfig::METHOD_PAYPAL, PayoneConfig::METHOD_PAYPALV2])) { |
||
| 124 | $blUseBilling = false; |
||
| 125 | } |
||
| 126 | $oQuote = $this->orderHelper->updateAddresses($oQuote, $aExpressAddressResponse, $blUseBilling); |
||
| 127 | } |
||
| 128 | |||
| 129 | $this->placeOrder($oQuote); |
||
| 130 | |||
| 131 | $sPayoneRedirectUrl = $this->checkoutSession->getPayoneRedirectUrl(); |
||
| 132 | if (!empty($sPayoneRedirectUrl)) { |
||
| 133 | $this->checkoutSession->setPayoneCustomerIsRedirected(true); |
||
| 134 | $this->checkoutSession->setPayonePayPalExpressRetry(true); |
||
| 135 | $this->_redirect($sPayoneRedirectUrl); |
||
| 136 | return; |
||
| 137 | } |
||
| 138 | |||
| 139 | // "last successful quote" |
||
| 140 | $sQuoteId = $oQuote->getId(); |
||
| 141 | $this->checkoutSession->setLastQuoteId($sQuoteId)->setLastSuccessQuoteId($sQuoteId)->unsPayoneWorkorderId()->unsIsPayonePayPalExpress()->unsPayoneUserAgent()->unsPayoneDeviceFingerprint(); |
||
| 142 | |||
| 143 | $oQuote->setIsActive(false)->save(); |
||
| 144 | |||
| 145 | $this->_redirect('checkout/onepage/success'); |
||
| 146 | } catch (\Exception $e) { |
||
| 147 | $this->messageManager->addExceptionMessage( |
||
| 148 | $e, |
||
| 149 | __('We can\'t place the order.') |
||
| 150 | ); |
||
| 151 | $this->_redirect('*/*/review'); |
||
| 152 | } |
||
| 193 |
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