Conditions | 11 |
Paths | 3 |
Total Lines | 82 |
Code Lines | 58 |
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 |
||
112 | public function parseResults(LoopResult $loopResult) |
||
113 | { |
||
114 | $lastLegacyRoundingOrderId = ConfigQuery::read('last_legacy_rounding_order_id', 0); |
||
115 | |||
116 | /** @var \Thelia\Model\OrderProduct $orderProduct */ |
||
117 | foreach ($loopResult->getResultDataCollection() as $orderProduct) { |
||
118 | $loopResultRow = new LoopResultRow($orderProduct); |
||
119 | |||
120 | $tax = $orderProduct->getVirtualColumn('TOTAL_TAX'); |
||
121 | $promoTax = $orderProduct->getVirtualColumn('TOTAL_PROMO_TAX'); |
||
122 | |||
123 | $totalTax = round($tax * $orderProduct->getQuantity(), 2); |
||
124 | $totalPromoTax = round($promoTax * $orderProduct->getQuantity(), 2); |
||
125 | |||
126 | // To prevent price changes in pre-2.4 orders, use the legacy calculation method |
||
127 | if ($orderProduct->getOrderId() <= $lastLegacyRoundingOrderId) { |
||
128 | $taxedPrice = $orderProduct->getPrice() + $orderProduct->getVirtualColumn('TOTAL_TAX'); |
||
129 | $taxedPromoPrice = $orderProduct->getPromoPrice() + $orderProduct->getVirtualColumn('TOTAL_PROMO_TAX'); |
||
130 | |||
131 | $totalPrice = $orderProduct->getPrice()*$orderProduct->getQuantity(); |
||
132 | $totalPromoPrice = $orderProduct->getPromoPrice()*$orderProduct->getQuantity(); |
||
133 | } else { |
||
134 | $taxedPrice = $orderProduct->getPrice() + $tax; |
||
135 | $taxedPromoPrice = $orderProduct->getPromoPrice() + $promoTax; |
||
136 | |||
137 | // Price calculation should use the same rounding method as in CartItem::getTotalTaxedPromoPrice() |
||
138 | // For each order line, we first round the taxed price, then we multiply by the quantity. |
||
139 | $totalPrice = round($orderProduct->getPrice() * $orderProduct->getQuantity(), 2); |
||
140 | $totalPromoPrice = round($orderProduct->getPromoPrice() * $orderProduct->getQuantity(), 2); |
||
141 | } |
||
142 | |||
143 | $totalTaxedPrice = round($taxedPrice * $orderProduct->getQuantity(), 2); |
||
144 | $totalTaxedPromoPrice = round($taxedPromoPrice * $orderProduct->getQuantity(), 2); |
||
145 | |||
146 | $loopResultRow->set('ID', $orderProduct->getId()) |
||
147 | ->set('REF', $orderProduct->getProductRef()) |
||
148 | ->set('PRODUCT_ID', $orderProduct->getVirtualColumn('product_id')) |
||
149 | ->set('PRODUCT_SALE_ELEMENTS_ID', $orderProduct->getProductSaleElementsId()) |
||
150 | ->set('PRODUCT_SALE_ELEMENTS_REF', $orderProduct->getProductSaleElementsRef()) |
||
151 | ->set('WAS_NEW', $orderProduct->getWasNew() === 1 ? 1 : 0) |
||
152 | ->set('WAS_IN_PROMO', $orderProduct->getWasInPromo() === 1 ? 1 : 0) |
||
153 | ->set('WEIGHT', $orderProduct->getWeight()) |
||
154 | ->set('TITLE', $orderProduct->getTitle()) |
||
155 | ->set('CHAPO', $orderProduct->getChapo()) |
||
156 | ->set('DESCRIPTION', $orderProduct->getDescription()) |
||
157 | ->set('POSTSCRIPTUM', $orderProduct->getPostscriptum()) |
||
158 | ->set('VIRTUAL', $orderProduct->getVirtual()) |
||
159 | ->set('VIRTUAL_DOCUMENT', $orderProduct->getVirtualDocument()) |
||
160 | ->set('QUANTITY', $orderProduct->getQuantity()) |
||
161 | |||
162 | ->set('PRICE', $orderProduct->getPrice()) |
||
163 | ->set('PRICE_TAX', $tax) |
||
164 | ->set('TAXED_PRICE', $taxedPrice) |
||
165 | ->set('PROMO_PRICE', $orderProduct->getPromoPrice()) |
||
166 | ->set('PROMO_PRICE_TAX', $promoTax) |
||
167 | ->set('TAXED_PROMO_PRICE', $taxedPromoPrice) |
||
168 | ->set('TOTAL_PRICE', $totalPrice) |
||
169 | ->set('TOTAL_TAXED_PRICE', $totalTaxedPrice) |
||
170 | ->set('TOTAL_PROMO_PRICE', $totalPromoPrice) |
||
171 | ->set('TOTAL_TAXED_PROMO_PRICE', $totalTaxedPromoPrice) |
||
172 | |||
173 | ->set('TAX_RULE_TITLE', $orderProduct->getTaxRuleTitle()) |
||
174 | ->set('TAX_RULE_DESCRIPTION', $orderProduct->getTaxRuledescription()) |
||
175 | ->set('PARENT', $orderProduct->getParent()) |
||
176 | ->set('EAN_CODE', $orderProduct->getEanCode()) |
||
177 | ->set('CART_ITEM_ID', $orderProduct->getCartItemId()) |
||
178 | |||
179 | ->set('REAL_PRICE', $orderProduct->getWasInPromo() ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) |
||
180 | ->set('REAL_TAXED_PRICE', $orderProduct->getWasInPromo() ? $taxedPromoPrice : $taxedPrice) |
||
181 | ->set('REAL_PRICE_TAX', $orderProduct->getWasInPromo() ? $promoTax : $tax) |
||
182 | |||
183 | ->set('REAL_TOTAL_PRICE', $orderProduct->getWasInPromo() ? $totalPromoPrice : $totalPrice) |
||
184 | ->set('REAL_TOTAL_TAXED_PRICE', $orderProduct->getWasInPromo() ? $totalTaxedPromoPrice : $totalTaxedPrice) |
||
185 | ->set('REAL_TOTAL_PRICE_TAX', $orderProduct->getWasInPromo() ? $totalPromoTax : $totalTax) |
||
186 | |||
187 | ; |
||
188 | $this->addOutputFields($loopResultRow, $orderProduct); |
||
189 | |||
190 | $loopResult->addRow($loopResultRow); |
||
191 | } |
||
192 | |||
193 | return $loopResult; |
||
194 | } |
||
196 |
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