Conditions | 7 |
Paths | 5 |
Total Lines | 55 |
Code Lines | 30 |
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 |
||
72 | public function build(array $buildSubject) |
||
73 | { |
||
74 | if (!isset($buildSubject['payment']) |
||
75 | || !$buildSubject['payment'] instanceof PaymentDataObjectInterface |
||
76 | ) { |
||
77 | throw new InvalidArgumentException('Payment data object should be provided'); |
||
78 | } |
||
79 | |||
80 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||
81 | |||
82 | $result = []; |
||
83 | |||
84 | $order = $paymentDO->getOrder(); |
||
85 | |||
86 | $grandTotal = $order->getGrandTotalAmount(); |
||
87 | |||
88 | $payment = $paymentDO->getPayment(); |
||
89 | |||
90 | $installment = $payment->getAdditionalInformation('cc_installments') ?: 1; |
||
91 | |||
92 | $totalFirst = $payment->getAdditionalInformation('cc_payment_first_amount'); |
||
93 | |||
94 | $amountFirst = $totalFirst; |
||
95 | |||
96 | if ($installment > 1) { |
||
97 | $storeId = $order->getStoreId(); |
||
98 | $interestFirst = $this->configCc->getInterestToAmount($installment, $totalFirst, $storeId); |
||
99 | $amountFirst = $totalFirst + $interestFirst; |
||
100 | } |
||
101 | |||
102 | $totalSecondary = $grandTotal - $totalFirst; |
||
103 | |||
104 | $installmentSecondary = $payment->getAdditionalInformation('cc_secondary_installments') ?: 1; |
||
105 | |||
106 | $amountSecondary = $totalSecondary; |
||
107 | |||
108 | if ($installmentSecondary > 1) { |
||
109 | $storeId = $order->getStoreId(); |
||
110 | $interestSecondary = $this->configCc->getInterestToAmount($installmentSecondary, $totalSecondary, $storeId); |
||
111 | $amountSecondary = $totalSecondary + $interestSecondary; |
||
112 | } |
||
113 | |||
114 | $result[self::AMOUNT] = $this->config->formatPrice(round($amountFirst + $amountSecondary, 2)); |
||
115 | |||
116 | $payment->setAdditionalInformation( |
||
117 | 'cc_payment_secondary_amount', |
||
118 | round($amountSecondary, 2) |
||
119 | ); |
||
120 | |||
121 | $payment->setAdditionalInformation( |
||
122 | 'cc_payment_first_amount', |
||
123 | round($amountFirst, 2) |
||
124 | ); |
||
125 | |||
126 | return $result; |
||
127 | } |
||
129 |
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