| Conditions | 5 |
| Paths | 6 |
| Total Lines | 66 |
| Code Lines | 45 |
| 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 |
||
| 56 | public function execute(array $commandSubject) |
||
| 57 | { |
||
| 58 | $storeAmount = $commandSubject['amount']; |
||
| 59 | $paymentDO = $commandSubject['payment']; |
||
| 60 | |||
| 61 | $payment = $paymentDO->getPayment(); |
||
| 62 | $order = $payment->getOrder(); |
||
| 63 | $storeId = $order->getStoreId(); |
||
| 64 | $walletId = $payment->getAdditionalInformation('wallet'); |
||
| 65 | |||
| 66 | if (empty($walletId)) { |
||
| 67 | $this->logger->critical('Payment Error: empty Wallet id.'); |
||
| 68 | |||
| 69 | throw new CommandException( |
||
| 70 | __('No currency provided.') |
||
| 71 | ); |
||
| 72 | } |
||
| 73 | |||
| 74 | $b2binpay = $this->adapterFactory->create($storeId); |
||
| 75 | |||
| 76 | try { |
||
| 77 | $wallet = $b2binpay->getWallet($walletId); |
||
| 78 | } catch (B2BinpayException $e) { |
||
| 79 | $this->logger->critical('Payment Error: ' . $e); |
||
| 80 | throw new CommandException(__('Payment method error.')); |
||
| 81 | } |
||
| 82 | |||
| 83 | $amount = $b2binpay->convertCurrency( |
||
| 84 | $storeAmount, |
||
| 85 | $order->getBaseCurrencyCode(), |
||
| 86 | $wallet->currency->alpha |
||
| 87 | ); |
||
| 88 | |||
| 89 | $markup = $this->config->getValue('markup', $storeId); |
||
| 90 | |||
| 91 | if (!empty($markup)) { |
||
| 92 | $amount = $b2binpay->addMarkup( |
||
| 93 | $amount, |
||
| 94 | $wallet->currency->alpha, |
||
| 95 | $markup |
||
| 96 | ); |
||
| 97 | } |
||
| 98 | |||
| 99 | try { |
||
| 100 | $bill = $b2binpay->createBill( |
||
| 101 | $wallet->id, |
||
| 102 | $amount, |
||
| 103 | $wallet->currency->alpha, |
||
| 104 | $this->config->getValue('lifetime', $storeId), |
||
| 105 | $order->getIncrementId(), |
||
| 106 | $this->urlBuilder->getUrl($this->config::CALLBACK_URI) |
||
| 107 | ); |
||
| 108 | } catch (B2BinpayException $e) { |
||
| 109 | $this->logger->critical('Payment Error: ' . $e); |
||
| 110 | throw new CommandException(__('Payment method error.')); |
||
| 111 | } |
||
| 112 | |||
| 113 | $payment->setAdditionalInformation('redirect_url', $bill->url) |
||
| 114 | ->setTransactionId($bill->id) |
||
| 115 | ->setIsTransactionClosed(false) |
||
| 116 | ->setIsTransactionPending(true); |
||
| 117 | |||
| 118 | $order->addStatusToHistory( |
||
| 119 | $order->getStatus(), |
||
| 120 | __('B2BinPay created new invoice for ') . $amount . $wallet->currency->alpha |
||
| 121 | )->save(); |
||
| 122 | } |
||
| 124 |
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