| Conditions | 18 |
| Paths | 209 |
| Total Lines | 100 |
| Code Lines | 64 |
| 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 |
||
| 113 | public function build(array $buildSubject) |
||
| 114 | { |
||
| 115 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||
| 116 | $payment = $paymentDO->getPayment(); |
||
| 117 | |||
| 118 | $result = []; |
||
| 119 | |||
| 120 | $orderAdapter = $this->orderAdapterFactory->create( |
||
| 121 | ['order' => $payment->getOrder()] |
||
| 122 | ); |
||
| 123 | |||
| 124 | $order = $paymentDO->getOrder(); |
||
| 125 | |||
| 126 | $storeId = $order->getStoreId(); |
||
| 127 | $useSplit = $this->config->getSplitValue('use_split', $storeId); |
||
| 128 | if (!$useSplit) { |
||
| 129 | return $result; |
||
| 130 | } |
||
| 131 | |||
| 132 | $addition = $orderAdapter->getTaxAmount(); |
||
| 133 | $interest = $orderAdapter->getBaseMoipInterestAmount(); |
||
| 134 | $grandTotal = $order->getGrandTotalAmount(); |
||
| 135 | $discount = $orderAdapter->getDiscountAmount(); |
||
| 136 | $total = $grandTotal + $interest; |
||
| 137 | if ($interest > 0) { |
||
| 138 | $total = $grandTotal - $interest; |
||
| 139 | } |
||
| 140 | |||
| 141 | $secondaryMPA = $this->config->getSplitValue('secondary_mpa', $storeId); |
||
| 142 | $secondaryPercent = $this->config->getSplitValue('secondary_percent', $storeId); |
||
| 143 | $commiUseShipping = $this->config->getSplitValue('secondary_percent_include_shipping', $storeId); |
||
| 144 | $commiUseInterest = $this->config->getSplitValue('secondary_percent_include_interest', $storeId); |
||
| 145 | |||
| 146 | if ($payment->getMethod() === 'moip_magento2_cc' || $payment->getMethod() === 'moip_magento2_cc_vault') { |
||
| 147 | if ($installment = $payment->getAdditionalInformation('cc_installments')) { |
||
| 148 | $interestInfo = $this->configCc->getInfoInterest($storeId); |
||
| 149 | if ($installment > 1) { |
||
| 150 | $typeInstallment = $this->configCc->getTypeInstallment($storeId); |
||
| 151 | if ($interestInfo[$installment] > 0) { |
||
| 152 | $installmentInterest = $this->getInterestCompound($total, $interestInfo[$installment], $installment); |
||
| 153 | if ($typeInstallment === 'simple') { |
||
| 154 | $installmentInterest = $this->getInterestSimple($total, $interestInfo[$installment], $installment); |
||
| 155 | } |
||
| 156 | |||
| 157 | if ($installmentInterest) { |
||
| 158 | $installmentInterest = number_format((float) $installmentInterest, 2, '.', ''); |
||
| 159 | $payment->setAdditionalInformation( |
||
| 160 | self::INSTALLMENT_INTEREST, |
||
| 161 | $this->priceHelper->currency($installmentInterest, true, false) |
||
| 162 | ); |
||
| 163 | if (!$interest) { |
||
| 164 | $orderAdapter->setMoipInterestAmount($installmentInterest)->setBaseMoipInterestAmount($installmentInterest); |
||
| 165 | } |
||
| 166 | $addition = $addition + $installmentInterest; |
||
| 167 | } |
||
| 168 | } |
||
| 169 | } elseif ((int) $installment === 1) { |
||
| 170 | if ($interestInfo[$installment] < 0) { |
||
| 171 | $totalWithDiscount = $grandTotal + ($interest * -1); |
||
| 172 | $discountInterest = $this->getInterestDiscount($totalWithDiscount, $interestInfo[$installment]); |
||
| 173 | $discountInterest = number_format((float) $discountInterest, 2, '.', ''); |
||
| 174 | |||
| 175 | $payment->setAdditionalInformation( |
||
| 176 | self::INSTALLMENT_INTEREST, |
||
| 177 | $this->priceHelper->currency($discountInterest, true, false) |
||
| 178 | ); |
||
| 179 | if (!$interest) { |
||
| 180 | $orderAdapter->setMoipInterestAmount($discountInterest)->setBaseMoipInterestAmount($discountInterest); |
||
| 181 | } |
||
| 182 | $interest = $discountInterest; |
||
| 183 | } |
||
| 184 | } |
||
| 185 | } |
||
| 186 | } |
||
| 187 | |||
| 188 | if (!$commiUseShipping) { |
||
| 189 | $total = $total - $orderAdapter->getShippingAmount(); |
||
| 190 | } |
||
| 191 | |||
| 192 | if ($commiUseInterest) { |
||
| 193 | if ($interest > 0) { |
||
| 194 | $total = $total + $addition; |
||
| 195 | } elseif ($interest < 0) { |
||
| 196 | $total = $total + $interest; |
||
| 197 | } |
||
| 198 | } |
||
| 199 | |||
| 200 | $commission = $total * ($secondaryPercent / 100); |
||
| 201 | |||
| 202 | $result[self::RECEIVERS][] = [ |
||
| 203 | self::RECEIVERS_MOIP_ACCOUNT => [ |
||
| 204 | self::RECEIVERS_MOIP_ACCOUNT_ID => $secondaryMPA, |
||
| 205 | ], |
||
| 206 | self::RECEIVERS_TYPE => self::RECEIVERS_TYPE_SECONDARY, |
||
| 207 | self::RECEIVERS_AMOUNT => [ |
||
| 208 | self::RECEIVERS_TYPE_FIXED => $this->config->formatPrice(round($commission, 2)), |
||
| 209 | ], |
||
| 210 | ]; |
||
| 211 | |||
| 212 | return $result; |
||
| 213 | } |
||
| 276 |
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