| Conditions | 14 |
| Paths | 52 |
| Total Lines | 84 |
| Code Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 114 | public function build(array $buildSubject) |
||
| 115 | { |
||
| 116 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||
| 117 | $payment = $paymentDO->getPayment(); |
||
| 118 | |||
| 119 | $result = []; |
||
| 120 | |||
| 121 | $orderAdapter = $this->orderAdapterFactory->create( |
||
| 122 | ['order' => $payment->getOrder()] |
||
| 123 | ); |
||
| 124 | |||
| 125 | $order = $paymentDO->getOrder(); |
||
| 126 | // $quoteId = $orderAdapter->getQuoteId(); |
||
| 127 | $storeId = $order->getStoreId(); |
||
| 128 | $addition = $orderAdapter->getTaxAmount(); |
||
| 129 | $interest = $orderAdapter->getBaseMoipInterestAmount(); |
||
| 130 | $grandTotal = $order->getGrandTotalAmount(); |
||
| 131 | $total = $grandTotal + $interest; |
||
| 132 | if ($interest > 0) { |
||
| 133 | $total = $grandTotal - $interest; |
||
| 134 | } |
||
| 135 | |||
| 136 | $discount = $orderAdapter->getDiscountAmount(); |
||
| 137 | |||
| 138 | if ($payment->getMethod() === 'moip_magento2_cc' || $payment->getMethod() === 'moip_magento2_cc_vault') { |
||
| 139 | if ($installment = $payment->getAdditionalInformation('cc_installments')) { |
||
| 140 | // $this->moipInterest->saveMoipInterest($quoteId, (int)$installment); |
||
| 141 | $interestInfo = $this->configCc->getInfoInterest($storeId); |
||
| 142 | if ($installment > 1) { |
||
| 143 | $typeInstallment = $this->configCc->getTypeInstallment($storeId); |
||
| 144 | if ($interestInfo[$installment] > 0) { |
||
| 145 | $installmentInterest = $this->getInterestCompound($total, $interestInfo[$installment], $installment); |
||
| 146 | if ($typeInstallment === 'simple') { |
||
| 147 | $installmentInterest = $this->getInterestSimple($total, $interestInfo[$installment], $installment); |
||
| 148 | } |
||
| 149 | |||
| 150 | if ($installmentInterest) { |
||
| 151 | $installmentInterest = number_format((float) $installmentInterest, 2, '.', ''); |
||
| 152 | $payment->setAdditionalInformation( |
||
| 153 | self::INSTALLMENT_INTEREST, |
||
| 154 | $this->priceHelper->currency($installmentInterest, true, false) |
||
| 155 | ); |
||
| 156 | if (!$interest) { |
||
| 157 | $orderAdapter->setMoipInterestAmount($installmentInterest)->setBaseMoipInterestAmount($installmentInterest); |
||
| 158 | } |
||
| 159 | $addition = $addition + $installmentInterest; |
||
| 160 | } |
||
| 161 | } |
||
| 162 | } elseif ((int) $installment === 1) { |
||
| 163 | if ($interestInfo[$installment] < 0) { |
||
| 164 | $totalWithDiscount = $grandTotal + ($interest * -1); |
||
| 165 | $discountInterest = $this->getInterestDiscount($totalWithDiscount, $interestInfo[$installment]); |
||
| 166 | $discountInterest = number_format((float) $discountInterest, 2, '.', ''); |
||
| 167 | |||
| 168 | $payment->setAdditionalInformation( |
||
| 169 | self::INSTALLMENT_INTEREST, |
||
| 170 | $this->priceHelper->currency($discountInterest, true, false) |
||
| 171 | ); |
||
| 172 | if (!$interest) { |
||
| 173 | $orderAdapter->setMoipInterestAmount($discountInterest)->setBaseMoipInterestAmount($discountInterest); |
||
| 174 | } |
||
| 175 | $interest = $discountInterest; |
||
| 176 | } |
||
| 177 | } |
||
| 178 | } |
||
| 179 | } |
||
| 180 | |||
| 181 | if ($interest < 0) { |
||
| 182 | $discount = $discount + $interest; |
||
| 183 | } |
||
| 184 | $discount = $discount * -1; |
||
| 185 | $result[self::TOTALS_AMOUNT] = [ |
||
| 186 | self::TOTALS_AMOUNT_CURRENCY => $order->getCurrencyCode(), |
||
| 187 | self::TOTALS_AMOUNT_GRAND_TOTAL => ceil($this->config->formatPrice($grandTotal)), |
||
| 188 | self::TOTALS_AMOUNT_SUBTOTALS => [ |
||
| 189 | self::TOTALS_AMOUNT_SUBTOTALS_SHIPPING => ceil($this->config->formatPrice( |
||
| 190 | $orderAdapter->getShippingAmount() |
||
| 191 | )), |
||
| 192 | self::TOTALS_AMOUNT_SUBTOTALS_DISCOUNT => ceil($this->config->formatPrice($discount)), |
||
| 193 | self::TOTALS_AMOUNT_SUBTOTALS_ADDITION => ceil($this->config->formatPrice($addition)), |
||
| 194 | ], |
||
| 195 | ]; |
||
| 196 | |||
| 197 | return $result; |
||
| 198 | } |
||
| 260 |
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